Export (0) Print
Expand All

ProviderSettings Class

Represents the configuration elements associated with a provider.

Namespace:  System.Configuration
Assembly:  System.Configuration (in System.Configuration.dll)

public sealed class ProviderSettings : ConfigurationElement

ASP.NET uses providers to perform specific services required by a feature. For example, the membership feature uses a provider to coordinate the persistence of membership data in a database.

In a configuration file, individual providers are added to a providers element within a particular feature section.

The ProviderSettings class represents a particular group of settings that are added to the providers element within a configuration section. Typically the configuration attributes specified by the add directive include a name, type, and other properties.

The following code example shows how to use the ProviderSettings.

using System;
using System.Collections;
using System.Collections.Specialized;
using System.Text;
using System.Configuration;
using System.Security.Permissions;

namespace Samples.AspNet
{

    // Shows how to use the ProviderSettings. 
    public class UsingProviderSettings
    {

        [PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
        private static void GetProviderSettings()
        {
            // Get the application configuration file.
            System.Configuration.Configuration config =
                    ConfigurationManager.OpenExeConfiguration(
                    ConfigurationUserLevel.None);

            ProtectedConfigurationSection pSection =
                config.GetSection("configProtectedData")
                as ProtectedConfigurationSection;

            ProviderSettingsCollection providerSettings =
              pSection.Providers;

            foreach (ProviderSettings pSettings in
                providerSettings)
            {


                Console.WriteLine(
                    "Provider settings name: {0}",
                    pSettings.Name);


                Console.WriteLine(
                    "Provider settings type: {0}",
                       pSettings.Type);

                NameValueCollection parameters =
                    pSettings.Parameters;

                IEnumerator pEnum =
                    parameters.GetEnumerator();

                int i = 0;
                while (pEnum.MoveNext())
                {
                    string pLength =
                        parameters[i].Length.ToString();
                    Console.WriteLine(
                        "Provider ssettings: {0} has {1} parameters",
                        pSettings.Name, pLength);

                }

            }

        }


        static void Main(string[] args)
        {

            GetProviderSettings();

        }
    }
}

The following is an excerpt of the configuration file used by the above example.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <configProtectedData>

    <providers>
      <clear />
      <add
         name="TripleDESProtectedConfigurationProvider" 
         type="Samples.Aspnet.TripleDESProtectedConfigurationProvider, protectedconfigurationproviderlib, Version=1.0.0.0, Culture=neutral, 
PublicKeyToken=79e01ae0f5cfc66f, processorArchitecture=MSIL" />

    </providers>

  </configProtectedData>

</configuration>

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0

Community Additions

ADD
Show:
© 2014 Microsoft