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ğinde türün nasıl kullanılacağı gösterilmektedir NameValueConfigurationCollection .

#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 program aracılığıyla bir nesne koleksiyonuna NameValueConfigurationElement erişmenizi sağlar.

Oluşturucular

Name Description
NameValueConfigurationCollection()

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

Özellikler

Name Description
AddElementName

türetilmiş bir sınıfta geçersiz kılındığında içindeki ConfigurationElement ekleme işlemiyle ilişkilendirilecek öğesinin adını ConfigurationElementCollection 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 ConfigurationElement net işlemle ilişkilendirilecek öğesinin adını ConfigurationElementCollection 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 Configuration örneğin ait olduğu yapılandırma hiyerarşisini temsil eden en üst düzey ConfigurationElement örneğe başvuru alır.

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

Özelleştirilebilir olmayan bilgileri ve nesnenin işlevselliğini ElementInformation içeren bir ConfigurationElement nesne 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

ContextInformation nesnesi için ConfigurationElement nesnesini alır.

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

özelliğinin CurrentConfigurationolup olmadığını null 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 ConfigurationElement remove işlemiyle ilişkilendirilecek öğesinin adını ConfigurationElementCollection alır veya ayarlar.

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

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

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

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

(Devralındığı yer: ConfigurationElementCollection)

Yöntemler

Name Description
Add(NameValueConfigurationElement)

Koleksiyona bir NameValueConfigurationElement nesne ekler.

BaseAdd(ConfigurationElement, Boolean)

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

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

öğesine ConfigurationElementCollectionbir 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 konumunda 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 yer alan 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 anahtarla öğesinin öğesinden ConfigurationElementkaldırılıp kaldırılmadığını ConfigurationElementCollection gösterir.

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

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

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

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

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

öğesini NameValueConfigurationCollectiontemizler.

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 IEnumeratoryinelemek için kullanılan bir ConfigurationElementCollection 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()

Geçerli örneğin Type 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 ConfigurationElementCollectionvar 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 Objectbasit 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)

Sağlanan parametreye göre bir NameValueConfigurationElement nesneyi koleksiyondan kaldırır.

Remove(String)

Sağlanan parametreye göre bir NameValueConfigurationElement nesneyi koleksiyondan kaldırır.

Reset(ConfigurationElement)

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

(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()

nesne ve IsReadOnly()ConfigurationElementCollection tüm alt öğeler için özelliğini ayarlar.

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

Geçerli nesneyi temsil eden bir dize 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ı

Name Description
ICollection.CopyTo(Array, Int32)

öğesini ConfigurationElementCollection bir diziye kopyalar.

(Devralındığı yer: ConfigurationElementCollection)

Uzantı Metotları

Name Description
AsParallel(IEnumerable)

Sorgunun paralelleştirilmesini etkinleştirir.

AsQueryable(IEnumerable)

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

Cast<TResult>(IEnumerable)

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

OfType<TResult>(IEnumerable)

Belirtilen türe göre bir IEnumerable öğesinin öğelerini filtreler.

Şunlara uygulanır

Ayrıca bkz.