Export (0) Print
Expand All

ProviderSettingsCollection Class

Note: This class is new in the .NET Framework version 2.0.

Represents a collection of ProviderSettings objects.

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

public sealed class ProviderSettingsCollection : ConfigurationElementCollection
public final class ProviderSettingsCollection extends ConfigurationElementCollection
public final class ProviderSettingsCollection extends ConfigurationElementCollection

The ProviderSettingsCollection class represents the providers element within a configuration file.

The following code example shows how to iterate through the Providers property, which returns a ProviderSettingsCollection.

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

namespace Samples.AspNet.Configuration
{

    // Show how to use a custom protected configuration
    // provider.
    public class UsingProviderSettings
    {

   
        private static void GetProviderSettings()
        {
            // Get the application configuration file.
            System.Configuration.Configuration config =
                    ConfigurationManager.OpenExeConfiguration(
                    ConfigurationUserLevel.None);

            ProtectedConfigurationSection pSection =
                config.GetSection("protectedData")
                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();

        
    


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 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 .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

Community Additions

ADD
Show:
© 2014 Microsoft