ConnectionStringSettings Klasa

Definicja

Reprezentuje pojedynczy, nazwany parametry połączenia w sekcji pliku konfiguracji parametrów połączenia.

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

Przykłady

W poniższym przykładzie pokazano, jak uzyskać dostęp do ConnectionStringSettings obiektu w danym indeksie ConnectionStringSettingsCollection w kolekcji.

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Web.Configuration;
using System.Collections;
using System.Text;

namespace ConfigurationStringSettings
{

    class ConfigurationStringSettings
    {

        static void DisplayConnectionStrings()
        {
            // Set the path of the config file.
            // Make sure that you have a Web site on the
            // same server called TestConfig. 
            string configPath = "/TestConfig";

            // Get the Web application configuration object.
            Configuration config =
              WebConfigurationManager.OpenWebConfiguration(configPath);

            // Get the conectionStrings section.
            ConnectionStringsSection csSection =
                config.ConnectionStrings;

            Console.WriteLine("Display configuration strings.");

            for (int i = 0; i <
                ConfigurationManager.ConnectionStrings.Count; i++)
            {
                ConnectionStringSettings cs =
                    csSection.ConnectionStrings[i];

                Console.WriteLine("  Connection String: \"{0}\"",
                    cs.ConnectionString);

                Console.WriteLine("#{0}", i);
                Console.WriteLine("  Name: {0}", cs.Name);

                Console.WriteLine("  Provider Name: {0}",
                    cs.ProviderName);
            }
        }

        static void Main(string[] args)
        {
            try
            {   // Display connection strings.
                DisplayConnectionStrings();
            }
            catch (Exception e)
            {
                // Unknown error.
                Console.WriteLine(e.ToString());
            }

            // Display and wait.
            Console.WriteLine("Enter any key to exit.");
            Console.ReadLine();
        }
    }
}
Imports System.Collections.Generic
Imports System.Configuration
Imports System.Web.Configuration
Imports System.Collections
Imports System.Text


Namespace ConfigurationStringSettings

    Class ConfigurationStringSettings

        Shared Sub DisplayConnectionStrings()
            ' Set the path of the config file.
            ' Make sure that you have a Web site on the
            ' same server called TestConfig. 
            Dim configPath As String = "/TestConfig"

            ' Get the Web application configuration object.
            Dim config As Configuration = _
            WebConfigurationManager.OpenWebConfiguration(configPath)


            ' Get the conectionStrings section.
            Dim csSection As ConnectionStringsSection = _
            config.ConnectionStrings

            Console.WriteLine("Display configuration strings.")

            Dim i As Integer = 0
            While i < ConfigurationManager.ConnectionStrings.Count
                Dim cs As ConnectionStringSettings = _
                csSection.ConnectionStrings(i)

                Console.WriteLine("  Connection String: ""{0}""", _
                                  cs.ConnectionString)

                Console.WriteLine("#{0}", i)
                Console.WriteLine("  Name: {0}", cs.Name)

                Console.WriteLine("  Provider Name: {0}", cs.ProviderName)
                System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1)
            End While

        End Sub


        Shared Sub Main(ByVal args As String())
            Try
                ' Display connection strings.
                DisplayConnectionStrings()
            Catch e As Exception
                ' Unknown error.
                Console.WriteLine(e.ToString())
            End Try

            ' Display and wait.
            Console.WriteLine("Enter any key to exit.")
            Console.ReadLine()
        End Sub
    End Class
End Namespace

Uwagi

Obiekt ConnectionStringSettings reprezentuje pojedynczy wpis w connectionStrings sekcji pliku konfiguracji.

Konstruktory

ConnectionStringSettings()

Inicjuje nowe wystąpienie klasy ConnectionStringSettings.

ConnectionStringSettings(String, String)

Inicjuje nowe wystąpienie klasy ConnectionStringSettings.

ConnectionStringSettings(String, String, String)

Inicjuje nowe wystąpienie klasy ConnectionStringSettings.

Właściwości

ConnectionString

Pobiera lub ustawia parametry połączenia.

CurrentConfiguration

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

(Odziedziczone po ConfigurationElement)
ElementInformation

ElementInformation Pobiera obiekt, który zawiera niezstosowalne informacje i funkcje ConfigurationElement obiektu.

(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ą, czy CurrentConfiguration właściwość to 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 ConnectionStringSettings nazwę.

Properties

Pobiera kolekcję właściwości.

(Odziedziczone po ConfigurationElement)
ProviderName

Pobiera lub ustawia właściwość nazwy dostawcy.

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 bieżące wystąpienie.

(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, gdy został zaimplementowany 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 znaleziono wymaganej właściwości.

(Odziedziczone po ConfigurationElement)
PostDeserialize()

Wywoływana po deserializacji.

(Odziedziczone po ConfigurationElement)
PreSerialize(XmlWriter)

Wywoływane 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ść obiektu ConfigurationElement i wszystkich podelementów.

(Odziedziczone po ConfigurationElement)
ToString()

Zwraca reprezentację ciągu obiektu.

Unmerge(ConfigurationElement, ConfigurationElement, ConfigurationSaveMode)

Modyfikuje obiekt, ConfigurationElement aby usunąć wszystkie wartości, które nie powinny być zapisywane.

(Odziedziczone po ConfigurationElement)

Dotyczy

Zobacz też