CanOption() public static method

判断可选状态是否为真
public static CanOption ( string name, ISession session ) : bool
name string
session ISession
return bool
コード例 #1
0
 public override void Process(TagHelperContext context, TagHelperOutput output)
 {
     if (CaptchaMiddleware.CanOption(CodeName, ViewContext.HttpContext.Session))
     {
         output.SuppressOutput();
     }
 }
コード例 #2
0
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            var httpContextAccessor = CaptchaMiddleware.ApplicationServices.GetService <IHttpContextAccessor>();
            var session             = httpContextAccessor.HttpContext.Session;

            if (CanOption && CaptchaMiddleware.CanOption(CodeName, session))
            {
                return(ValidationResult.Success);
            }
            else
            {
                var codeValue = session.GetString(CaptchaMiddleware.SessionKeyPrefix_Value + CodeName);
                return(Valid(value, codeValue));
            }
        }