Sdílet prostřednictvím


ProtectedConfigurationSection.Providers Vlastnost

Definice

ProviderSettingsCollection Získá kolekci ProtectedConfigurationProvider všech objektů ve všech zúčastněných konfiguračních souborech.

public:
 property System::Configuration::ProviderSettingsCollection ^ Providers { System::Configuration::ProviderSettingsCollection ^ get(); };
[System.Configuration.ConfigurationProperty("providers")]
public System.Configuration.ProviderSettingsCollection Providers { get; }
public System.Configuration.ProviderSettingsCollection Providers { get; }
[<System.Configuration.ConfigurationProperty("providers")>]
member this.Providers : System.Configuration.ProviderSettingsCollection
member this.Providers : System.Configuration.ProviderSettingsCollection
Public ReadOnly Property Providers As ProviderSettingsCollection

Hodnota vlastnosti

Kolekce ProviderSettingsCollection všech ProtectedConfigurationProvider objektů ve všech zúčastněných konfiguračních souborech.

Atributy

Příklady

Následující příklad kódu ukazuje, jak použít Providers vlastnost.

static void GetProviderCollection()
{

    try
    {
        // Get the application configuration.
        Configuration config =
            ConfigurationManager.OpenExeConfiguration(
            ConfigurationUserLevel.None);

        // Get the protected configuration section.
        ProtectedConfigurationSection pcSection =
            (System.Configuration.ProtectedConfigurationSection)
            config.GetSection("configProtectedData");

        Console.WriteLine(
       "Protected configuration section providers:");
        foreach (ProviderSettings ps in
        pcSection.Providers)
        {
            Console.WriteLine("  {0}", ps.Name);
        }
    }
    catch (ConfigurationErrorsException e)
    {
        Console.WriteLine(e.ToString());
    }
}
Shared Sub GetProviderCollection() 
    
    Try
        ' Get the application configuration.
        Dim config As Configuration = _
        ConfigurationManager.OpenExeConfiguration( _
        ConfigurationUserLevel.None)

        ' Get the protected configuration section.
        Dim pcSection _
        As ProtectedConfigurationSection = _
        CType(config.GetSection( _
        "configProtectedData"), _
        System.Configuration.ProtectedConfigurationSection)

        Console.WriteLine( _
        "Protected configuration section providers:")
        Dim ps As ProviderSettings
        For Each ps In  pcSection.Providers
            Console.WriteLine("  {0}", ps.Name)
        Next ps
    
    Catch e As ConfigurationErrorsException
        Console.WriteLine(e.ToString())
    End Try

End Sub

Platí pro