ProviderSettings Klasa

Definicja

Reprezentuje elementy konfiguracji skojarzone z dostawcą.

public ref class ProviderSettings sealed : System::Configuration::ConfigurationElement
public sealed class ProviderSettings : System.Configuration.ConfigurationElement
type ProviderSettings = class
    inherit ConfigurationElement
Public NotInheritable Class ProviderSettings
Inherits ConfigurationElement
Dziedziczenie
ProviderSettings

Przykłady

W poniższym przykładzie kodu pokazano, jak używać metody 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();
        }
    }
}
Imports System.Collections
Imports System.Collections.Specialized
Imports System.Text
Imports System.Configuration
Imports System.Security.Permissions


' Shows how to use the ProviderSettings.
Namespace Samples.AspNet


    Public Class UsingProviderSettings


        <PermissionSet( _
           SecurityAction.Demand, Name:="FullTrust")> _
           Private Shared Sub GetProviderSettings()
            ' Get the application configuration file.
            Dim config _
            As System.Configuration.Configuration = _
            ConfigurationManager.OpenExeConfiguration( _
            ConfigurationUserLevel.None)

            Dim pSection As _
            ProtectedConfigurationSection = _
            config.GetSection("configProtectedData")

            Dim providerSettings _
            As ProviderSettingsCollection = _
            pSection.Providers

            Dim pSettings As ProviderSettings
            For Each pSettings In providerSettings

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


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

                Dim parameters _
                As NameValueCollection = pSettings.Parameters

                Dim pEnum _
                As IEnumerator = parameters.GetEnumerator()

                Dim i As Integer = 0
                While pEnum.MoveNext()
                    Dim pLength As String = _
                    parameters(i).Length.ToString()
                    Console.WriteLine( _
                    "Provider ssettings: {0} has {1} parameters", _
                    pSettings.Name, pLength)
                End While
            Next pSettings

        End Sub


        Public Shared Sub Main(ByVal args() As String)

            GetProviderSettings()
        End Sub
    End Class

End Namespace

Poniżej znajduje się fragment pliku konfiguracji używanego w powyższym przykładzie.

<?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>  

Uwagi

ASP.NET używa dostawców do wykonywania określonych usług wymaganych przez funkcję. Na przykład funkcja członkostwa używa dostawcy do koordynowania trwałości danych członkostwa w bazie danych.

W pliku konfiguracji indywidualni dostawcy są dodawani do providers elementu w określonej sekcji funkcji.

Klasa ProviderSettings reprezentuje określoną grupę ustawień, które są dodawane do providers elementu w sekcji konfiguracji. Zazwyczaj atrybuty konfiguracji określone przez dyrektywę add obejmują nazwę, typ i inne właściwości.

Konstruktory

ProviderSettings()

Inicjuje nowe wystąpienie klasy ProviderSettings.

ProviderSettings(String, String)

Inicjuje nowe wystąpienie klasy ProviderSettings.

Właściwości

CurrentConfiguration

Pobiera odwołanie do wystąpienia najwyższego poziomu Configuration reprezentującego hierarchię konfiguracji, do którego należy bieżące ConfigurationElement wystąpienie.

(Odziedziczone po ConfigurationElement)
ElementInformation

ElementInformation Pobiera obiekt, który zawiera informacje i funkcje ConfigurationElement obiektu, które nie można dostosowywać.

(Odziedziczone po ConfigurationElement)
ElementProperty

ConfigurationElementProperty Pobiera obiekt reprezentujący ConfigurationElement sam obiekt.

(Odziedziczone po ConfigurationElement)
EvaluationContext

ContextInformation Pobiera obiekt dla ConfigurationElement obiektu.

(Odziedziczone po ConfigurationElement)
HasContext

Pobiera wartość wskazującą CurrentConfiguration , czy właściwość ma wartość null.

(Odziedziczone po ConfigurationElement)
Item[ConfigurationProperty]

Pobiera lub ustawia właściwość lub atrybut tego elementu konfiguracji.

(Odziedziczone po ConfigurationElement)
Item[String]

Pobiera lub ustawia właściwość, atrybut lub element podrzędny tego elementu konfiguracji.

(Odziedziczone po ConfigurationElement)
LockAllAttributesExcept

Pobiera kolekcję zablokowanych atrybutów.

(Odziedziczone po ConfigurationElement)
LockAllElementsExcept

Pobiera kolekcję zablokowanych elementów.

(Odziedziczone po ConfigurationElement)
LockAttributes

Pobiera kolekcję zablokowanych atrybutów.

(Odziedziczone po ConfigurationElement)
LockElements

Pobiera kolekcję zablokowanych elementów.

(Odziedziczone po ConfigurationElement)
LockItem

Pobiera lub ustawia wartość wskazującą, czy element jest zablokowany.

(Odziedziczone po ConfigurationElement)
Name

Pobiera lub ustawia nazwę dostawcy skonfigurowanego przez tę klasę.

Parameters

Pobiera kolekcję parametrów zdefiniowanych przez użytkownika dla dostawcy.

Properties

Pobiera kolekcję właściwości.

(Odziedziczone po ConfigurationElement)
Type

Pobiera lub ustawia typ dostawcy skonfigurowanego przez tę klasę.

Metody

DeserializeElement(XmlReader, Boolean)

Odczytuje kod XML z pliku konfiguracji.

(Odziedziczone po ConfigurationElement)
Equals(Object)

Porównuje bieżące ConfigurationElement wystąpienie z określonym obiektem.

(Odziedziczone po ConfigurationElement)
GetHashCode()

Pobiera unikatową wartość reprezentującą bieżące ConfigurationElement wystąpienie.

(Odziedziczone po ConfigurationElement)
GetTransformedAssemblyString(String)

Zwraca przekształconą wersję określonej nazwy zestawu.

(Odziedziczone po ConfigurationElement)
GetTransformedTypeString(String)

Zwraca przekształconą wersję określonej nazwy typu.

(Odziedziczone po ConfigurationElement)
GetType()

Type Pobiera wartość bieżącego wystąpienia.

(Odziedziczone po Object)
Init()

ConfigurationElement Ustawia obiekt na stan początkowy.

(Odziedziczone po ConfigurationElement)
InitializeDefault()

Służy do inicjowania domyślnego zestawu wartości dla ConfigurationElement obiektu.

(Odziedziczone po ConfigurationElement)
IsModified()

Wskazuje, czy ten element konfiguracji został zmodyfikowany od czasu ostatniego zapisania lub załadowania, podczas implementacji w klasie pochodnej.

(Odziedziczone po ConfigurationElement)
IsReadOnly()

Pobiera wartość wskazującą, czy ConfigurationElement obiekt jest tylko do odczytu.

(Odziedziczone po ConfigurationElement)
ListErrors(IList)

Dodaje błędy nieprawidłowej właściwości w tym ConfigurationElement obiekcie i we wszystkich podelementach do przekazanej listy.

(Odziedziczone po ConfigurationElement)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
OnDeserializeUnrecognizedAttribute(String, String)

Pobiera wartość wskazującą, czy podczas deserializacji napotkano nieznany atrybut.

(Odziedziczone po ConfigurationElement)
OnDeserializeUnrecognizedElement(String, XmlReader)

Pobiera wartość wskazującą, czy podczas deserializacji napotkano nieznany element.

(Odziedziczone po ConfigurationElement)
OnRequiredPropertyNotFound(String)

Zgłasza wyjątek, gdy nie można odnaleźć wymaganej właściwości.

(Odziedziczone po ConfigurationElement)
PostDeserialize()

Wywoływana po deserializacji.

(Odziedziczone po ConfigurationElement)
PreSerialize(XmlWriter)

Wywoływana przed serializacji.

(Odziedziczone po ConfigurationElement)
Reset(ConfigurationElement)

Resetuje stan ConfigurationElement wewnętrzny obiektu, w tym blokady i kolekcje właściwości.

(Odziedziczone po ConfigurationElement)
ResetModified()

Resetuje wartość IsModified() metody w false przypadku implementacji w klasie pochodnej.

(Odziedziczone po ConfigurationElement)
SerializeElement(XmlWriter, Boolean)

Zapisuje zawartość tego elementu konfiguracji do pliku konfiguracji po zaimplementowaniu w klasie pochodnej.

(Odziedziczone po ConfigurationElement)
SerializeToXmlElement(XmlWriter, String)

Zapisuje zewnętrzne tagi tego elementu konfiguracji do pliku konfiguracji po zaimplementowaniu w klasie pochodnej.

(Odziedziczone po ConfigurationElement)
SetPropertyValue(ConfigurationProperty, Object, Boolean)

Ustawia właściwość na określoną wartość.

(Odziedziczone po ConfigurationElement)
SetReadOnly()

IsReadOnly() Ustawia właściwość dla ConfigurationElement obiektu i wszystkich podelementów.

(Odziedziczone po ConfigurationElement)
ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)
Unmerge(ConfigurationElement, ConfigurationElement, ConfigurationSaveMode)

Modyfikuje obiekt w ConfigurationElement celu usunięcia wszystkich wartości, które nie powinny być zapisywane.

(Odziedziczone po ConfigurationElement)

Dotyczy

Zobacz też