System.Configuration.ProtectedConfigurationProviderCollection.Add C# (CSharp) Method

Add() public method

public Add ( ProviderBase provider ) : void
provider System.Configuration.Provider.ProviderBase
return void
        public override void Add(ProviderBase provider)
        {
            if( provider == null )
            {
                throw new ArgumentNullException( "provider" );
            }

            if( !( provider is ProtectedConfigurationProvider ) )
           {
                throw new ArgumentException(SR.GetString(SR.Config_provider_must_implement_type, typeof(ProtectedConfigurationProvider).ToString()), "provider");
           }

            base.Add( provider );
        }

Usage Example

        ///////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////
#if CACHE_PROVIDERS_IN_STATIC
        private static void InstantiateProviders()
        {
            if (_Providers != null)
            {
                return;
            }

            lock (_Lock)
            {
                if (_Providers != null)
                {
                    return;
                }

                ProtectedConfigurationProviderCollection providers = new ProtectedConfigurationProviderCollection();
                ProtectedConfigurationSection            config    = PrivilegedConfigurationManager.GetSection(BaseConfigurationRecord.RESERVED_SECTION_PROTECTED_CONFIGURATION) as ProtectedConfigurationSection;

                if (config != null)
                {
                    foreach (DictionaryEntry de in config.ProviderNodes)
                    {
                        ProviderNode pn = de.Value as ProviderNode;

                        if (pn == null)
                        {
                            continue;
                        }

                        providers.Add(pn.Provider);
                    }
                }

                _Providers = providers;
            }
        }
All Usage Examples Of System.Configuration.ProtectedConfigurationProviderCollection::Add
ProtectedConfigurationProviderCollection