/// <summary> /// 初始化 /// </summary> /// <param name="name"></param> /// <param name="config"></param> public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config) { if (config == null) throw new ArgumentNullException("config"); if (String.IsNullOrEmpty(name)) name = "CrosshatchAutoInputProtectionFilterProvider"; if (string.IsNullOrEmpty(config["description"])) { config.Remove("description"); config.Add("description", "Crosshatch Auto-Input Protection Filter Provider"); } base.Initialize(name, config); VerificationCodeProviderHelper helper = new VerificationCodeProviderHelper(config); opacity = helper.ParseSingle("opacity", false, .15F); randomStyle = helper.ParseBoolean("randomStyle", false, true); style = helper.ParseEnum("style", false, HatchStyle.DiagonalCross); colors.AddRange(helper.ParseCollection<Color>("colors", false, true, false, ',')); if (colors.Count == 0) colors.Add(Color.Black); // Throw an exception if unrecognized attributes remain if (config.Count > 0) { string attr = config.GetKey(0); if (!String.IsNullOrEmpty(attr)) throw new Exception(string.Format(System.Globalization.CultureInfo.CurrentUICulture, "Resources.Errors.UnrecognizedAttribute", attr)); } }
/// <summary> /// 初始化 /// </summary> /// <param name="name"></param> /// <param name="config"></param> public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config) { if (config == null) throw new ArgumentNullException("config"); if (String.IsNullOrEmpty(name)) name = "LineNoiseAutoInputProtectionImageProvider"; if (string.IsNullOrEmpty(config["description"])) { config.Remove("description"); config.Add("description", "Line Noise Auto-Input Protection Image Provider"); } VerificationCodeProviderHelper helper = new VerificationCodeProviderHelper(config); colors.AddRange(helper.ParseCollection<Color>("colors", false, true, false, ',')); base.Initialize(name, config); // Throw an exception if unrecognized attributes remain if (config.Count > 0) { string attr = config.GetKey(0); if (!String.IsNullOrEmpty(attr)) throw new ProviderException(string.Format(System.Globalization.CultureInfo.CurrentUICulture, "Errors.UnrecognizedAttribute", attr)); } }
/// <summary> /// Loads the provider's settings from the specified <paramref name="config"/>. /// </summary> /// <exception cref="System.Configuration.Provider.ProviderException">An attribute value cannot be converted into the required type.</exception> /// <param name="name">Name of the provider.</param> /// <param name="config">A collection of name and value pairs that will be used to initialize the provider.</param> public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config) { if (config == null) throw new ArgumentNullException("config"); base.Initialize(name, config); VerificationCodeProviderHelper helper = new VerificationCodeProviderHelper(config); margin = helper.ParseInt32("margin", false, -1); minRotation = helper.ParseInt32("minimumCharacterRotation", false, -1); maxRotation = helper.ParseInt32("maximumCharacterRotation", false, -1); }