NameValueConfigurationCollection Sınıf

Tanım

Bir nesne koleksiyonu NameValueConfigurationElement içerir. Bu sınıf devralınamaz.

public ref class NameValueConfigurationCollection sealed : System::Configuration::ConfigurationElementCollection
[System.Configuration.ConfigurationCollection(typeof(System.Configuration.NameValueConfigurationElement))]
public sealed class NameValueConfigurationCollection : System.Configuration.ConfigurationElementCollection
[<System.Configuration.ConfigurationCollection(typeof(System.Configuration.NameValueConfigurationElement))>]
type NameValueConfigurationCollection = class
    inherit ConfigurationElementCollection
Public NotInheritable Class NameValueConfigurationCollection
Inherits ConfigurationElementCollection
Devralma
Öznitelikler

Örnekler

Aşağıdaki kod örneği, türün NameValueConfigurationCollection nasıl kullanılacağını gösterir.

#region Using directives

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

#endregion

namespace Samples.AspNet
{
    class UsingNameValueConfigurationCollection
    {
        static void Main(string[] args)
        {
            try
            {
                // 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 section related object.
                AnonymousIdentificationSection configSection =
                  (AnonymousIdentificationSection)config.GetSection
                  ("system.web/anonymousIdentification");

                // Display title and info.
                Console.WriteLine("Configuration Info");
                Console.WriteLine();

                // Display Config details.
                Console.WriteLine("File Path: {0}",
                  config.FilePath);
                Console.WriteLine("Section Path: {0}",
                  configSection.SectionInformation.Name);
                Console.WriteLine();

                // Create a NameValueConfigurationCollection object.
                NameValueConfigurationCollection myNameValConfigCollection =
                  new NameValueConfigurationCollection();

                foreach (PropertyInformation propertyItem in
                  configSection.ElementInformation.Properties)
                {
                    // Assign  domain name.
                    if (propertyItem.Name == "domain")
                        propertyItem.Value = "MyDomain";

                    if (propertyItem.Value != null)
                    {
                        // Enable SSL for cookie exchange.
                        if (propertyItem.Name == "cookieRequireSSL")
                            propertyItem.Value = true;

                        NameValueConfigurationElement nameValConfigElement =
                            new NameValueConfigurationElement
                                (propertyItem.Name.ToString(), propertyItem.Value.ToString());

                        // Add a NameValueConfigurationElement
                        // to the collection.
                        myNameValConfigCollection.Add(nameValConfigElement);
                    }
                }

                // Count property.
                Console.WriteLine("Collection Count: {0}",
                 myNameValConfigCollection.Count);

                // Item property.
                Console.WriteLine("Value of property 'enabled': {0}",
                 myNameValConfigCollection["enabled"].Value);

                // Display the contents of the collection.
                foreach (NameValueConfigurationElement configItem
                  in myNameValConfigCollection)
                {
                    Console.WriteLine();
                    Console.WriteLine("Configuration Details:");
                    Console.WriteLine("Name: {0}", configItem.Name);
                    Console.WriteLine("Value: {0}", configItem.Value);
                }

                // Assign the domain calue.
                configSection.Domain = myNameValConfigCollection["domain"].Value;
                // Assign the SSL required value.
                if (myNameValConfigCollection["cookieRequireSSL"].Value == "true")
                    configSection.CookieRequireSSL = true;

                // Remove domain from the collection.
                NameValueConfigurationElement myConfigElement =
                    myNameValConfigCollection["domain"];
                // Remove method.
                myNameValConfigCollection.Remove(myConfigElement);

                // Save changes to the configuration file.
                // This modifies the Web.config of the TestConfig site.
                config.Save(ConfigurationSaveMode.Minimal, true);

                // Clear the collection.
                myNameValConfigCollection.Clear();
            }

            catch (Exception e)
            {
                // Unknown error.
                Console.WriteLine(e.ToString());
            }

            // Display and wait.
            Console.ReadLine();
        }
    }
}
Imports System.Configuration
Imports System.Web
Imports System.Collections
Imports System.Text


Namespace Samples.AspNet
    Class UsingNameValueConfigurationCollection
        Public Shared Sub Main(ByVal args As String())
            Try
                ' 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 = _
                System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(configPath)

                ' Get the section related object.
                Dim configSection _
                As System.Web.Configuration.AnonymousIdentificationSection = _
                DirectCast(config.GetSection("system.web/anonymousIdentification"),  _
                System.Web.Configuration.AnonymousIdentificationSection)

                ' Display title and info.
                Console.WriteLine("Configuration Info")
                Console.WriteLine()

                ' Display Config details.
                Console.WriteLine("File Path: {0}", config.FilePath)
                Console.WriteLine("Section Path: {0}", configSection.SectionInformation.Name)
                Console.WriteLine()

                ' Create a NameValueConfigurationCollection object.
                Dim myNameValConfigCollection As New NameValueConfigurationCollection()

                For Each propertyItem As PropertyInformation In configSection.ElementInformation.Properties
                    ' Assign  domain name.
                    If propertyItem.Name = "domain" Then
                        propertyItem.Value = "MyDomain"
                    End If

                    If propertyItem.Value <> Nothing Then
                        ' Enable SSL for cookie exchange.
                        If propertyItem.Name = "cookieRequireSSL" Then
                            propertyItem.Value = True
                        End If

                        Dim nameValConfigElement As New NameValueConfigurationElement(propertyItem.Name.ToString(), propertyItem.Value.ToString())

                        ' Add a NameValueConfigurationElement
                        ' to the collection.

                        myNameValConfigCollection.Add(nameValConfigElement)
                    End If
                Next

                ' Count property.
                Console.WriteLine("Collection Count: {0}", myNameValConfigCollection.Count)

                ' Item property.
                Console.WriteLine("Value of property 'enabled': {0}", myNameValConfigCollection("enabled").Value)

                ' Display the contents of the collection.
                For Each configItem As NameValueConfigurationElement In myNameValConfigCollection
                    Console.WriteLine()
                    Console.WriteLine("Configuration Details:")
                    Console.WriteLine("Name: {0}", configItem.Name)
                    Console.WriteLine("Value: {0}", configItem.Value)
                Next

                ' Assign the domain calue.
                configSection.Domain = myNameValConfigCollection("domain").Value
                ' Assign the SSL required value.
                If myNameValConfigCollection("cookieRequireSSL").Value = "true" Then
                    configSection.CookieRequireSSL = True
                End If

                ' Remove domain from the collection.
                Dim myConfigElement As NameValueConfigurationElement = myNameValConfigCollection("domain")
                ' Remove method.
                myNameValConfigCollection.Remove(myConfigElement)

                ' Save changes to the configuration file.
                ' This modifies the Web.config of the TestConfig site.
                config.Save(ConfigurationSaveMode.Minimal, True)

                ' Clear the collection.
                myNameValConfigCollection.Clear()
            Catch e As Exception

                ' Unknown error.
                Console.WriteLine(e.ToString())
            End Try

            ' Display and wait.
            Console.ReadLine()
        End Sub
    End Class
End Namespace

Açıklamalar

sınıfı, NameValueConfigurationCollection bir nesne koleksiyonuna NameValueConfigurationElement program aracılığıyla erişmenizi sağlar.

Oluşturucular

NameValueConfigurationCollection()

NameValueConfigurationCollection sınıfının yeni bir örneğini başlatır.

Özellikler

AddElementName

Türetilmiş bir sınıfta geçersiz kılındığında içindeki ConfigurationElementCollection ekleme işlemiyle ilişkilendirilecek öğesinin adını ConfigurationElement alır veya ayarlar.

(Devralındığı yer: ConfigurationElementCollection)
AllKeys

içindeki tüm öğelerin NameValueConfigurationCollectionanahtarlarını alır.

ClearElementName

türetilmiş bir sınıfta geçersiz kılındığında içindeki clear işlemiyle ilişkilendirilecek öğesinin ConfigurationElementCollection adını ConfigurationElement alır veya ayarlar.

(Devralındığı yer: ConfigurationElementCollection)
CollectionType

türünü ConfigurationElementCollectionalır.

(Devralındığı yer: ConfigurationElementCollection)
Count

Koleksiyondaki öğe sayısını alır.

(Devralındığı yer: ConfigurationElementCollection)
CurrentConfiguration

Geçerli ConfigurationElement örneğin ait olduğu yapılandırma hiyerarşisini temsil eden en üst düzey Configuration örneğe başvuru alır.

(Devralındığı yer: ConfigurationElement)
ElementInformation

Nesnenin özelleştirilebilir olmayan bilgilerini ve işlevselliğini ConfigurationElement içeren bir ElementInformation nesnesi alır.

(Devralındığı yer: ConfigurationElement)
ElementName

Türetilmiş bir sınıfta geçersiz kılındığında yapılandırma dosyasındaki bu öğe koleksiyonunu tanımlamak için kullanılan adı alır.

(Devralındığı yer: ConfigurationElementCollection)
ElementProperty

Nesnenin ConfigurationElementProperty kendisini temsil ConfigurationElement eden nesneyi alır.

(Devralındığı yer: ConfigurationElement)
EmitClear

Koleksiyonun temizlenip temizlenmediğini belirten bir değer alır veya ayarlar.

(Devralındığı yer: ConfigurationElementCollection)
EvaluationContext

Nesnenin ContextInformation nesnesini ConfigurationElement alır.

(Devralındığı yer: ConfigurationElement)
HasContext

özelliğinin nullolup olmadığını CurrentConfiguration gösteren bir değer alır.

(Devralındığı yer: ConfigurationElement)
IsSynchronized

Koleksiyona erişimin eşitlenip eşitlenmediğini belirten bir değer alır.

(Devralındığı yer: ConfigurationElementCollection)
Item[ConfigurationProperty]

Bu yapılandırma öğesinin özelliğini veya özniteliğini alır veya ayarlar.

(Devralındığı yer: ConfigurationElement)
Item[String]

Sağlanan parametreye NameValueConfigurationElement göre nesnesini alır veya ayarlar.

LockAllAttributesExcept

Kilitli özniteliklerin koleksiyonunu alır.

(Devralındığı yer: ConfigurationElement)
LockAllElementsExcept

Kilitli öğeler koleksiyonunu alır.

(Devralındığı yer: ConfigurationElement)
LockAttributes

Kilitli özniteliklerin koleksiyonunu alır.

(Devralındığı yer: ConfigurationElement)
LockElements

Kilitli öğeler koleksiyonunu alır.

(Devralındığı yer: ConfigurationElement)
LockItem

Öğesinin kilitli olup olmadığını belirten bir değer alır veya ayarlar.

(Devralındığı yer: ConfigurationElement)
Properties

Özellik koleksiyonunu alır.

(Devralındığı yer: ConfigurationElement)
RemoveElementName

Türetilmiş bir sınıfta geçersiz kılındığında içindeki ConfigurationElementCollection kaldırma işlemiyle ilişkilendirilecek öğesinin adını ConfigurationElement alır veya ayarlar.

(Devralındığı yer: ConfigurationElementCollection)
SyncRoot

öğesine erişimi ConfigurationElementCollectioneşitlemek için kullanılan bir nesneyi alır.

(Devralındığı yer: ConfigurationElementCollection)
ThrowOnDuplicate

öğesine yineleme ConfigurationElement ekleme girişiminin ConfigurationElementCollection özel durum oluşturulup oluşturulmayacağını belirten bir değer alır.

(Devralındığı yer: ConfigurationElementCollection)

Yöntemler

Add(NameValueConfigurationElement)

Koleksiyona bir NameValueConfigurationElement nesne ekler.

BaseAdd(ConfigurationElement)

öğesine ConfigurationElementCollectionbir yapılandırma öğesi ekler.

(Devralındığı yer: ConfigurationElementCollection)
BaseAdd(ConfigurationElement, Boolean)

Yapılandırma öğesi koleksiyonuna bir yapılandırma öğesi ekler.

(Devralındığı yer: ConfigurationElementCollection)
BaseAdd(Int32, ConfigurationElement)

Yapılandırma öğesi koleksiyonuna bir yapılandırma öğesi ekler.

(Devralındığı yer: ConfigurationElementCollection)
BaseClear()

Koleksiyondaki tüm yapılandırma öğesi nesnelerini kaldırır.

(Devralındığı yer: ConfigurationElementCollection)
BaseGet(Int32)

Belirtilen dizin konumundaki yapılandırma öğesini alır.

(Devralındığı yer: ConfigurationElementCollection)
BaseGet(Object)

Belirtilen anahtarla yapılandırma öğesini döndürür.

(Devralındığı yer: ConfigurationElementCollection)
BaseGetAllKeys()

içinde bulunan tüm yapılandırma öğeleri için anahtarların bir dizisini ConfigurationElementCollectiondöndürür.

(Devralındığı yer: ConfigurationElementCollection)
BaseGetKey(Int32)

Belirtilen dizin konumunda anahtarını ConfigurationElement alır.

(Devralındığı yer: ConfigurationElementCollection)
BaseIndexOf(ConfigurationElement)

Belirtilen ConfigurationElementöğesinin dizinini gösterir.

(Devralındığı yer: ConfigurationElementCollection)
BaseIsRemoved(Object)

Belirtilen anahtara sahip öğesinin öğesinden ConfigurationElementCollectionkaldırılıp kaldırılmadığını ConfigurationElement gösterir.

(Devralındığı yer: ConfigurationElementCollection)
BaseRemove(Object)

ConfigurationElement Bir öğesini koleksiyondan kaldırır.

(Devralındığı yer: ConfigurationElementCollection)
BaseRemoveAt(Int32)

ConfigurationElement Belirtilen dizin konumunda öğesini kaldırır.

(Devralındığı yer: ConfigurationElementCollection)
Clear()

öğesini temizler NameValueConfigurationCollection.

CopyTo(ConfigurationElement[], Int32)

öğesinin ConfigurationElementCollection içeriğini bir diziye kopyalar.

(Devralındığı yer: ConfigurationElementCollection)
CreateNewElement()

Türetilmiş bir sınıfta geçersiz kılındığında yeni ConfigurationElementbir oluşturur.

(Devralındığı yer: ConfigurationElementCollection)
CreateNewElement(String)

Türetilmiş bir sınıfta geçersiz kılındığında yeni ConfigurationElement bir oluşturur.

(Devralındığı yer: ConfigurationElementCollection)
DeserializeElement(XmlReader, Boolean)

Yapılandırma dosyasından XML okur.

(Devralındığı yer: ConfigurationElement)
Equals(Object)

öğesini ConfigurationElementCollection belirtilen nesneyle karşılaştırır.

(Devralındığı yer: ConfigurationElementCollection)
GetElementKey(ConfigurationElement)

Türetilmiş bir sınıfta geçersiz kılındığında belirtilen yapılandırma öğesinin öğe anahtarını alır.

(Devralındığı yer: ConfigurationElementCollection)
GetEnumerator()

aracılığıyla ConfigurationElementCollectionyinelemek için kullanılan bir IEnumerator alır.

(Devralındığı yer: ConfigurationElementCollection)
GetHashCode()

Örneği temsil eden ConfigurationElementCollection benzersiz bir değer alır.

(Devralındığı yer: ConfigurationElementCollection)
GetTransformedAssemblyString(String)

Belirtilen derleme adının dönüştürülmüş sürümünü döndürür.

(Devralındığı yer: ConfigurationElement)
GetTransformedTypeString(String)

Belirtilen tür adının dönüştürülmüş sürümünü döndürür.

(Devralındığı yer: ConfigurationElement)
GetType()

Type Geçerli örneğini alır.

(Devralındığı yer: Object)
Init()

ConfigurationElement Nesneyi ilk durumuna ayarlar.

(Devralındığı yer: ConfigurationElement)
InitializeDefault()

Nesne için varsayılan değer kümesini başlatmak için ConfigurationElement kullanılır.

(Devralındığı yer: ConfigurationElement)
IsElementName(String)

Belirtilen ConfigurationElement öğesinin içinde ConfigurationElementCollectionmevcut olup olmadığını gösterir.

(Devralındığı yer: ConfigurationElementCollection)
IsElementRemovable(ConfigurationElement)

Belirtilen ConfigurationElement öğesinin öğesinden ConfigurationElementCollectionkaldırılıp kaldırılamayacağını gösterir.

(Devralındığı yer: ConfigurationElementCollection)
IsModified()

Bunun ConfigurationElementCollection , türetilmiş bir sınıfta son kaydedildiğinden veya geçersiz kılındığında yüklendiğinden beri değiştirilip değiştirilmediğini gösterir.

(Devralındığı yer: ConfigurationElementCollection)
IsReadOnly()

Nesnenin ConfigurationElementCollection salt okunur olup olmadığını gösterir.

(Devralındığı yer: ConfigurationElementCollection)
ListErrors(IList)

Bu ConfigurationElement nesnedeki ve tüm alt öğelerdeki invalid-property hatalarını geçirilen listeye ekler.

(Devralındığı yer: ConfigurationElement)
MemberwiseClone()

Geçerli Objectöğesinin sığ bir kopyasını oluşturur.

(Devralındığı yer: Object)
OnDeserializeUnrecognizedAttribute(String, String)

Seri durumdan çıkarma sırasında bilinmeyen bir öznitelikle karşılaşılıp karşılaşılmadığını belirten bir değer alır.

(Devralındığı yer: ConfigurationElement)
OnDeserializeUnrecognizedElement(String, XmlReader)

Yapılandırma sisteminin özel durum oluşturmasına neden olur.

(Devralındığı yer: ConfigurationElementCollection)
OnRequiredPropertyNotFound(String)

Gerekli bir özellik bulunamadığında bir özel durum oluşturur.

(Devralındığı yer: ConfigurationElement)
PostDeserialize()

Seri durumdan çıkarıldıktan sonra çağrılır.

(Devralındığı yer: ConfigurationElement)
PreSerialize(XmlWriter)

Serileştirmeden önce çağrılır.

(Devralındığı yer: ConfigurationElement)
Remove(NameValueConfigurationElement)

NameValueConfigurationElement Sağlanan parametreyi temel alarak bir nesneyi koleksiyondan kaldırır.

Remove(String)

NameValueConfigurationElement Sağlanan parametreyi temel alarak bir nesneyi koleksiyondan kaldırır.

Reset(ConfigurationElement)

türetilmiş bir sınıfta geçersiz kılındığında öğesini değiştirilmemiş durumuna sıfırlar ConfigurationElementCollection .

(Devralındığı yer: ConfigurationElementCollection)
ResetModified()

Türetilmiş bir sınıfta geçersiz kılındığında özelliğinin IsModified()false değerini olarak sıfırlar.

(Devralındığı yer: ConfigurationElementCollection)
SerializeElement(XmlWriter, Boolean)

Türetilmiş bir sınıfta geçersiz kılındığında yapılandırma verilerini yapılandırma dosyasındaki bir XML öğesine yazar.

(Devralındığı yer: ConfigurationElementCollection)
SerializeToXmlElement(XmlWriter, String)

Türetilmiş bir sınıfta uygulandığında bu yapılandırma öğesinin dış etiketlerini yapılandırma dosyasına yazar.

(Devralındığı yer: ConfigurationElement)
SetPropertyValue(ConfigurationProperty, Object, Boolean)

Bir özelliği belirtilen değere ayarlar.

(Devralındığı yer: ConfigurationElement)
SetReadOnly()

nesnesinin IsReadOnly() ve tüm alt öğelerinin ConfigurationElementCollection özelliğini ayarlar.

(Devralındığı yer: ConfigurationElementCollection)
ToString()

Geçerli nesneyi temsil eden dizeyi döndürür.

(Devralındığı yer: Object)
Unmerge(ConfigurationElement, ConfigurationElement, ConfigurationSaveMode)

Yapılandırma bilgilerini yapılandırma hiyerarşisinin farklı düzeylerinden birleştirmenin etkisini tersine çevirir.

(Devralındığı yer: ConfigurationElementCollection)

Belirtik Arabirim Kullanımları

ICollection.CopyTo(Array, Int32)

öğesini ConfigurationElementCollection bir diziye kopyalar.

(Devralındığı yer: ConfigurationElementCollection)

Uzantı Metotları

Cast<TResult>(IEnumerable)

öğesinin IEnumerable öğelerini belirtilen türe atar.

OfType<TResult>(IEnumerable)

Öğesinin IEnumerable öğelerini belirtilen türe göre filtreler.

AsParallel(IEnumerable)

Sorgunun paralelleştirilmesini etkinleştirir.

AsQueryable(IEnumerable)

bir IEnumerable öğesini öğesine IQueryabledönüştürür.

Şunlara uygulanır

Ayrıca bkz.