Функция Chr конвертирует целое число IntValue или в AnsiChar или в WideChar
string _pass = Encoding.ASCII.GetString(new byte[] { 27, 8, 30, 23, 31, 22, 2, 24, 127 });
public static Func<CookieValidateIdentityContext, Task> OnValidateIdentity()
{
return SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser, int>(TimeSpan.FromMinutes(30), GetIdentityAsync, id => id.GetUserId<int>());
}
public static async Task<ClaimsIdentity> GetIdentityAsync(ApplicationUserManager manager, ApplicationUser user)
{
var userIdentity = await manager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie);
//userIdentity.AddClaim(new Claim("FriendlyName", friendlyName));
//userIdentity.AddClaim(new Claim("balance", balance.ToString(CultureInfo.CurrentCulture)));
//userIdentity.AddClaim(new Claim("sms", sms.ToString()));
//userIdentity.AddClaim(new Claim("minutes", minutes.ToString()));
return userIdentity;
}
Provider = new CookieAuthenticationProvider
{
OnValidateIdentity = ApplicationSignInManager.OnValidateIdentity()
}
public string Test2()
{
return "большие ботинки";
}
.method public hidebysig specialname instance string
get_Test() cil managed
{
.maxstack 1
.locals init (
[0] string V_0
)
// [13 17 - 13 18]
IL_0000: nop
// [13 19 - 13 44]
IL_0001: ldstr "большие ботинки"
IL_0006: stloc.0 // V_0
IL_0007: br.s IL_0009
// [13 45 - 13 46]
IL_0009: ldloc.0 // V_0
IL_000a: ret
} // end of method Class1::get_Test
.method public hidebysig instance string
Test2() cil managed
{
.maxstack 1
.locals init (
[0] string V_0
)
// [17 9 - 17 10]
IL_0000: nop
// [18 13 - 18 38]
IL_0001: ldstr "большие ботинки"
IL_0006: stloc.0 // V_0
IL_0007: br.s IL_0009
// [19 9 - 19 10]
IL_0009: ldloc.0 // V_0
IL_000a: ret
} // end of method Class1::Test2
List<string> words = new List<string> { "hello", "World" };
string pattern = "("+ string.Join("|", words) + "),";
Console.WriteLine(pattern);
Regex r = new Regex(pattern, RegexOptions.IgnoreCase);
string text = "Hello, World, hello world heelo";
var matches = r.Matches(text);
foreach(var match in matches){
Console.WriteLine(match);
}
public class ValidateModelAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
if (filterContext.Controller.ViewData.ModelState.IsValid == false)
{
if (filterContext.ActionParameters.Count == 1)
{
filterContext.Controller.ViewData.Model = filterContext.ActionParameters.FirstOrDefault().Value;
filterContext.Result = new ViewResult
{
ViewData = filterContext.Controller.ViewData
};
}
else
{
throw new HttpException(400, "validation model error");
}
}
}
}