private static void InitialImageProviders(bool hasSection, VerificationCodeSection section)
        {
            if (hasSection)
            {
                //根据给定的Provider类型和提供的节点配置初始化对应的ProviderCollection
                ProvidersHelper.InstantiateProviders(section.ImageProviders,ImageProviderCollection,typeof(VerificationCodeImageProvider));

                if (
                    section.DefaultImageProvider.Equals(
                        section.ElementInformation.Properties["defaultImageProvider"].DefaultValue))
                {
                    if (ImageProviderCollection.Count > 0) imageProvider = ImageProviderCollection[0];
                    else imageProvider = new LineNoiseVerificationCodeImageProvider();
                }
                else
                {
                    imageProvider = ImageProviderCollection[section.DefaultImageProvider];
                }

                if(imageProvider == null) throw new InvalidOperationException("验证码图片配置有误");
            }
            else if (imageProvider == null)
            {
                section.ImageProviders.Add(CreateProviderSettings(section.DefaultImageProvider,typeof(LineNoiseVerificationCodeImageProvider)));
                ProvidersHelper.InstantiateProviders(section.ImageProviders,ImageProviderCollection,typeof(VerificationCodeImageProvider));
                imageProvider = ImageProviderCollection[section.DefaultImageProvider];
            }
        }
        private static void InitializeTextProviders(bool isHasSection, VerificationCodeSection section)
        {
            if (isHasSection)
            {
                ProvidersHelper.InstantiateProviders(section.TextProviders, TextProviderCollection,
                    typeof (VerificationCodeTextProvider));

                if (
                    section.DefaultTextProvider.Equals(
                        section.ElementInformation.Properties["defaultTextProvider"].DefaultValue))
                {
                    if (TextProviderCollection.Count > 0)
                        textProvider = TextProviderCollection[0];
                    else
                    {
                        textProvider =
                            new BasicEnglishVerificationCodeTextProvider(new[] {Color.Black, Color.Red, Color.Brown},
                                new[]
                                {
                                    new Font("Times New Roman", 1), new Font("Arial", 1),
                                    new Font("Microsoft Sans Serif", 1)
                                });
                    }

                }
                else
                {
                    textProvider = TextProviderCollection[section.DefaultTextProvider];
                }

                if (textProvider == null) throw new InvalidOperationException("验证码字符配置出错");
            }
            else if (textProvider == null)
            {
                section.TextProviders.Add(CreateProviderSettings(section.DefaultTextProvider,
                    typeof (BasicEnglishVerificationCodeTextProvider),
                    new KeyValuePair<string, string>("colors", "Red,Green,Blue,Brown"),
                    new KeyValuePair<string, string>("fonts", "Times New Roman, Arial, Microsoft Sans Serif")));
                ProvidersHelper.InstantiateProviders(section.TextProviders, TextProviderCollection,
                    typeof (VerificationCodeTextProvider));
                textProvider = TextProviderCollection[section.DefaultTextProvider];
            }
        }
        private static void EnsureProviders()
        {
            VerificationCodeSection verificationCodeSection = (VerificationCodeSection)WebConfigurationManager.GetSection("");
            bool hasSection = verificationCodeSection != null;
            if (!hasSection) verificationCodeSection = new VerificationCodeSection();

            persistenceMode = verificationCodeSection.PersistenceMode;
            InitializeTextProviders(hasSection, verificationCodeSection);
            InitialImageProviders(hasSection, verificationCodeSection);

            ProviderSettingsCollection pc = new ProviderSettingsCollection();
            pc.Add(new ProviderSettings("filter", "ShepherdsFramework.Framework.Utilities.Captcha.CrosshatchVerificationCodeFilterProvider,ShepherdsFramework.Framework.Utilities.Captcha"));
            ProvidersHelper.InstantiateProviders(pc,FilterProviderCollection,typeof(VerificationCodeFilterProvider));
        }