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
public final class ProviderSettings extends ConfigurationElement
public final class ProviderSettings extends ConfigurationElement
Not applicable.

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>

System.Object
   System.Configuration.ConfigurationElement
    System.Configuration.ProviderSettings

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 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show:
© 2014 Microsoft