Пример #1
0
        /// <summary>
        /// 按动作类型  获取验证码类型
        /// </summary>
        /// <param name="actionType"></param>
        /// <returns></returns>
        public static ValidateCodeType GetValidateCodeTypeByAction(string actionType)
        {
            string codeTypeString = null;

            foreach (ValidateCode tempValidateCode in AllSettings.Current.ValidateCodeSettings.ValidateCodes)
            {
                if (string.Compare(tempValidateCode.ActionType, actionType, true) == 0)
                {
                    codeTypeString = tempValidateCode.ValidateCodeType;
                    break;
                }
            }

            ValidateCodeType validateCodeType = null;

            if (codeTypeString == null)
            {
            }
            else
            {
                validateCodeType = GetValidateCodeType(codeTypeString);
            }

            if (validateCodeType == null)
            {
                validateCodeType = new ValidateCode_Style1();
            }

            return(validateCodeType);
        }
Пример #2
0
        /// <summary>
        /// 获取验证码
        /// </summary>
        /// <param name="actionType">动作类型</param>
        /// <param name="validateCode"></param>
        /// <param name="remark"></param>
        /// <returns></returns>
        public static byte[] CreateImage(string actionType, out string validateCode)
        {
            ValidateCodeType validateCodeType = GetValidateCodeTypeByAction(actionType);

            if (validateCodeType == null)
            {
                validateCode = string.Empty;
                return(null);
            }
            return(validateCodeType.CreateImage(out validateCode));
        }
Пример #3
0
 /// <summary>
 /// 注册一个验证码样式
 /// </summary>
 /// <param name="mission"></param>
 public static void RegisterValidateCodeType(ValidateCodeType validateCodeType)
 {
     lock (registValidateCodeTypeLocker)
     {
         if (GetValidateCodeType(validateCodeType.Type) == null)
         {
             validateCodeTypes.Add(validateCodeType);
         }
         //else
         //{
         //    throw new Exception(string.Format(Lang_Error.ValidateCode_RegistValidateCodeTypeError,validateCodeType.Type));
         //}
     }
 }
Пример #4
0
 /// <summary>
 /// 注册一个验证码样式
 /// </summary>
 /// <param name="mission"></param>
 public static void RegisterValidateCodeType(ValidateCodeType validateCodeType)
 {
     lock (registValidateCodeTypeLocker)
     {
         if (GetValidateCodeType(validateCodeType.Type) == null)
             validateCodeTypes.Add(validateCodeType);
         //else
         //{
         //    throw new Exception(string.Format(Lang_Error.ValidateCode_RegistValidateCodeTypeError,validateCodeType.Type));
         //}
     }
 }