for (int i = runs.Count - 1; i >= 0;)
if(runs.Remove(equals[e]))
i--;
private ClaimsIdentity GetClaims(User user)
{
List<Claim> claims = new List<Claim>();
claims.Add(new Claim(ClaimTypes.NameIdentifier, user.UserName));
claims.Add(new Claim(ClaimTypes.Role, user.Role));
claims.Add(new Claim(CustomClaimsTypes.IsActive, user.IsActive.ToString()));
return new ClaimsIdentity(claims);
}
var tokenDescriptor = new SecurityTokenDescriptor
{
Subject = GetClaims(user),
Expires = claimTime,
Audience = auth.Audience,
Issuer = auth.Issuer,
SigningCredentials = auth.Credentials
};
var name = HttpContext.User.Claims.FirstOrDefault(f => f.Type == ClaimTypes.NameIdentifier).Value;
public interface IMessage
{
void SendMessage(string msg);
}
public abstract class MessageBase : IMessage
{
public virtual void SendMessage(string msg) => Console.WriteLine($@"{Name}:parameter={msg}");
public abstract string Name { get; }
}
public class Bye : MessageBase {public override string Name => "Bye"; }
public class Hello : MessageBase {public override string Name => "Hello"; }
public class Welcome : MessageBase { public override string Name => "Welcome";}
class ReflectMethod
{
public static void InvokeMethod(string[] array)
{
List<IMessage> messages = new List<IMessage>()
{
new Bye(),
new Hello(),
new Welcome()
};
for (int counter = 0; counter < array.Length; counter++)
{
messages[counter].SendMessage(array[counter]);
}
}
}
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
<Button Content="нажать" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="KeyDown">
<i:InvokeCommandAction Command="{Binding KeyDownCommand}" CommandParameter="param"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>