Beispiel #1
0
        public Captcha(CaptchaConfig captchaConfig)
        {
            CaptchaConfig = captchaConfig ?? new CaptchaConfig();

            captchaConfig.FontColors = captchaConfig.FontColors ?? new Color[] {
                Color.FromArgb(44, 62, 80), Color.FromArgb(192, 57, 43), Color.FromArgb(22, 160, 133),
                Color.FromArgb(192, 57, 42), Color.FromArgb(142, 68, 173),
                Color.FromArgb(48, 63, 159), Color.FromArgb(245, 124, 0), Color.FromArgb(121, 85, 72)
            };
        }
Beispiel #2
0
 public Captcha()
 {
     //读取配置文件
     try
     {
         CaptchaConfig = AppConfig.GetSection("Captcha")?.GetBindData <CaptchaConfig>() ?? new CaptchaConfig()
         {
             FontColors = new Color[] {
                 Color.FromArgb(44, 62, 80), Color.FromArgb(192, 57, 43), Color.FromArgb(22, 160, 133),
                 Color.FromArgb(192, 57, 42), Color.FromArgb(142, 68, 173),
                 Color.FromArgb(48, 63, 159), Color.FromArgb(245, 124, 0), Color.FromArgb(121, 85, 72)
             }
         };
     }
     catch (Exception ex)
     {
         throw new Exception("读取配置文件出错", ex);
     }
 }
 /// <summary>
 /// 验证码服务注入
 /// </summary>
 /// <param name="services"></param>
 public static void AddCaptchaAsProperties(this ContainerBuilder services, CaptchaConfig captchaConfig)
 {
     services.Register(q => new Captcha(captchaConfig)).As <ICaptcha>().SingleInstance().PropertiesAutowired();
 }