NameValueConfigurationCollection 클래스

정의

NameValueConfigurationElement 개체의 컬렉션을 포함합니다. 이 클래스는 상속될 수 없습니다.

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
상속
특성

예제

다음 코드 예제를 사용 하는 방법에 설명 합니다 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

설명

합니다 NameValueConfigurationCollection 클래스의 컬렉션을 프로그래밍 방식으로 액세스할 수 있습니다 NameValueConfigurationElement 개체입니다.

생성자

NameValueConfigurationCollection()

NameValueConfigurationCollection 클래스의 새 인스턴스를 초기화합니다.

속성

AddElementName

파생 클래스에서 재정의될 때 ConfigurationElement의 추가 작업과 연결할 ConfigurationElementCollection의 이름을 가져오거나 설정합니다.

(다음에서 상속됨 ConfigurationElementCollection)
AllKeys

NameValueConfigurationCollection에 포함된 모든 항목에 대한 키를 가져옵니다.

ClearElementName

파생 클래스에서 재정의될 때 ConfigurationElement의 지우기 작업과 연결할 ConfigurationElementCollection의 이름을 가져오거나 설정합니다.

(다음에서 상속됨 ConfigurationElementCollection)
CollectionType

ConfigurationElementCollection의 형식을 가져옵니다.

(다음에서 상속됨 ConfigurationElementCollection)
Count

컬렉션의 요소 수를 가져옵니다.

(다음에서 상속됨 ConfigurationElementCollection)
CurrentConfiguration

현재 Configuration 인스턴스가 속해 있는 구성 계층 구조를 나타내는 최상위 ConfigurationElement 인스턴스에 대한 참조를 가져옵니다.

(다음에서 상속됨 ConfigurationElement)
ElementInformation

ElementInformation 개체의 사용자 지정할 수 없는 정보와 기능을 포함하는 ConfigurationElement 개체를 가져옵니다.

(다음에서 상속됨 ConfigurationElement)
ElementName

파생 클래스에서 재정의될 때 구성 파일에서 이 요소 컬렉션을 식별하는 데 사용되는 이름을 가져옵니다.

(다음에서 상속됨 ConfigurationElementCollection)
ElementProperty

ConfigurationElementProperty 개체 자체를 나타내는 ConfigurationElement 개체를 가져옵니다.

(다음에서 상속됨 ConfigurationElement)
EmitClear

컬렉션이 지워졌는지 여부를 지정하는 값을 가져오거나 설정합니다.

(다음에서 상속됨 ConfigurationElementCollection)
EvaluationContext

ContextInformation 개체의 ConfigurationElement 개체를 가져옵니다.

(다음에서 상속됨 ConfigurationElement)
HasContext

CurrentConfiguration 속성이 null인지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 ConfigurationElement)
IsSynchronized

컬렉션에 대한 액세스가 동기화되었는지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 ConfigurationElementCollection)
Item[ConfigurationProperty]

이 구성 요소의 속성이나 특성을 가져오거나 설정합니다.

(다음에서 상속됨 ConfigurationElement)
Item[String]

제공된 매개 변수에 따라 NameValueConfigurationElement 개체를 가져오거나 설정합니다.

LockAllAttributesExcept

잠긴 특성의 컬렉션을 가져옵니다.

(다음에서 상속됨 ConfigurationElement)
LockAllElementsExcept

잠긴 요소의 컬렉션을 가져옵니다.

(다음에서 상속됨 ConfigurationElement)
LockAttributes

잠긴 특성의 컬렉션을 가져옵니다.

(다음에서 상속됨 ConfigurationElement)
LockElements

잠긴 요소의 컬렉션을 가져옵니다.

(다음에서 상속됨 ConfigurationElement)
LockItem

요소가 잠겨 있는지 여부를 나타내는 값을 가져오거나 설정합니다.

(다음에서 상속됨 ConfigurationElement)
Properties

속성 컬렉션을 가져옵니다.

(다음에서 상속됨 ConfigurationElement)
RemoveElementName

파생 클래스에서 재정의될 때 ConfigurationElement의 제거 작업과 연결할 ConfigurationElementCollection의 이름을 가져오거나 설정합니다.

(다음에서 상속됨 ConfigurationElementCollection)
SyncRoot

ConfigurationElementCollection에 대한 액세스를 동기화하는 데 사용되는 개체를 가져옵니다.

(다음에서 상속됨 ConfigurationElementCollection)
ThrowOnDuplicate

ConfigurationElement에 중복 ConfigurationElementCollection를 추가하려고 하면 예외가 throw되는지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 ConfigurationElementCollection)

메서드

Add(NameValueConfigurationElement)

컬렉션에 NameValueConfigurationElement 개체를 추가합니다.

BaseAdd(ConfigurationElement)

구성 요소를 ConfigurationElementCollection에 추가합니다.

(다음에서 상속됨 ConfigurationElementCollection)
BaseAdd(ConfigurationElement, Boolean)

구성 요소를 구성 요소 컬렉션에 추가합니다.

(다음에서 상속됨 ConfigurationElementCollection)
BaseAdd(Int32, ConfigurationElement)

구성 요소를 구성 요소 컬렉션에 추가합니다.

(다음에서 상속됨 ConfigurationElementCollection)
BaseClear()

컬렉션에서 구성 요소 개체를 모두 제거합니다.

(다음에서 상속됨 ConfigurationElementCollection)
BaseGet(Int32)

지정된 인덱스 위치에 있는 구성 요소를 가져옵니다.

(다음에서 상속됨 ConfigurationElementCollection)
BaseGet(Object)

지정된 키가 있는 구성 요소를 반환합니다.

(다음에서 상속됨 ConfigurationElementCollection)
BaseGetAllKeys()

ConfigurationElementCollection에 포함된 모든 구성 요소의 키 배열을 반환합니다.

(다음에서 상속됨 ConfigurationElementCollection)
BaseGetKey(Int32)

지정된 인덱스 위치에 있는 ConfigurationElement의 키를 가져옵니다.

(다음에서 상속됨 ConfigurationElementCollection)
BaseIndexOf(ConfigurationElement)

지정된 ConfigurationElement의 인덱스를 나타냅니다.

(다음에서 상속됨 ConfigurationElementCollection)
BaseIsRemoved(Object)

지정된 키가 있는 ConfigurationElementConfigurationElementCollection에서 제거되었는지 여부를 나타냅니다.

(다음에서 상속됨 ConfigurationElementCollection)
BaseRemove(Object)

컬렉션에서 ConfigurationElement를 제거합니다.

(다음에서 상속됨 ConfigurationElementCollection)
BaseRemoveAt(Int32)

지정된 인덱스 위치에서 ConfigurationElement를 제거합니다.

(다음에서 상속됨 ConfigurationElementCollection)
Clear()

NameValueConfigurationCollection을 지웁니다.

CopyTo(ConfigurationElement[], Int32)

ConfigurationElementCollection의 내용을 배열에 복사합니다.

(다음에서 상속됨 ConfigurationElementCollection)
CreateNewElement()

파생 클래스에서 재정의할 때 새 ConfigurationElement를 만듭니다.

(다음에서 상속됨 ConfigurationElementCollection)
CreateNewElement(String)

파생 클래스에서 재정의될 때 새 ConfigurationElement를 만듭니다.

(다음에서 상속됨 ConfigurationElementCollection)
DeserializeElement(XmlReader, Boolean)

구성 파일에서 XML을 읽습니다.

(다음에서 상속됨 ConfigurationElement)
Equals(Object)

ConfigurationElementCollection을 지정된 개체와 비교합니다.

(다음에서 상속됨 ConfigurationElementCollection)
GetElementKey(ConfigurationElement)

파생 클래스에서 재정의될 때 지정된 구성 요소의 요소 키를 가져옵니다.

(다음에서 상속됨 ConfigurationElementCollection)
GetEnumerator()

IEnumerator을 반복하는 데 사용되는 ConfigurationElementCollection를 가져옵니다.

(다음에서 상속됨 ConfigurationElementCollection)
GetHashCode()

ConfigurationElementCollection 인스턴스를 나타내는 고유 값을 가져옵니다.

(다음에서 상속됨 ConfigurationElementCollection)
GetTransformedAssemblyString(String)

지정된 어셈블리 이름의 변환된 버전을 반환합니다.

(다음에서 상속됨 ConfigurationElement)
GetTransformedTypeString(String)

지정된 형식 이름의 변환된 버전을 반환합니다.

(다음에서 상속됨 ConfigurationElement)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
Init()

ConfigurationElement 개체를 초기 상태로 설정합니다.

(다음에서 상속됨 ConfigurationElement)
InitializeDefault()

ConfigurationElement 개체 값의 기본 집합을 초기화하는 데 사용됩니다.

(다음에서 상속됨 ConfigurationElement)
IsElementName(String)

지정된 ConfigurationElementConfigurationElementCollection에 있는지 여부를 나타냅니다.

(다음에서 상속됨 ConfigurationElementCollection)
IsElementRemovable(ConfigurationElement)

지정한 ConfigurationElementConfigurationElementCollection에서 제거할 수 있는지 여부를 나타냅니다.

(다음에서 상속됨 ConfigurationElementCollection)
IsModified()

파생 클래스에서 재정의될 때 이 ConfigurationElementCollection이 마지막으로 저장되거나 로드된 후 수정되었는지 여부를 나타냅니다.

(다음에서 상속됨 ConfigurationElementCollection)
IsReadOnly()

ConfigurationElementCollection 개체가 읽기 전용인지 여부를 나타냅니다.

(다음에서 상속됨 ConfigurationElementCollection)
ListErrors(IList)

ConfigurationElement 개체와 모든 하위 요소의 잘못된 속성 오류를 전달된 목록에 추가합니다.

(다음에서 상속됨 ConfigurationElement)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
OnDeserializeUnrecognizedAttribute(String, String)

역직렬화하는 동안 알 수 없는 특성을 발견했는지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 ConfigurationElement)
OnDeserializeUnrecognizedElement(String, XmlReader)

구성 시스템에서 예외를 throw하도록 합니다.

(다음에서 상속됨 ConfigurationElementCollection)
OnRequiredPropertyNotFound(String)

필수 속성이 없으면 예외를 throw합니다.

(다음에서 상속됨 ConfigurationElement)
PostDeserialize()

deserialization 후에 호출됩니다.

(다음에서 상속됨 ConfigurationElement)
PreSerialize(XmlWriter)

serialization 전에 호출됩니다.

(다음에서 상속됨 ConfigurationElement)
Remove(NameValueConfigurationElement)

제공된 매개 변수에 따라 컬렉션에서 NameValueConfigurationElement 개체를 제거합니다.

Remove(String)

제공된 매개 변수에 따라 컬렉션에서 NameValueConfigurationElement 개체를 제거합니다.

Reset(ConfigurationElement)

파생 클래스에서 재정의될 때 ConfigurationElementCollection을 수정되지 않은 상태로 다시 설정합니다.

(다음에서 상속됨 ConfigurationElementCollection)
ResetModified()

파생 클래스에서 재정의될 때 IsModified() 속성의 값을 false로 다시 설정합니다.

(다음에서 상속됨 ConfigurationElementCollection)
SerializeElement(XmlWriter, Boolean)

파생 클래스에서 재정의될 때 구성 파일의 XML 요소에 구성 데이터를 씁니다.

(다음에서 상속됨 ConfigurationElementCollection)
SerializeToXmlElement(XmlWriter, String)

파생 클래스에서 구현될 때 구성 요소의 외부 태그를 구성 파일에 씁니다.

(다음에서 상속됨 ConfigurationElement)
SetPropertyValue(ConfigurationProperty, Object, Boolean)

속성을 지정된 값으로 설정합니다.

(다음에서 상속됨 ConfigurationElement)
SetReadOnly()

IsReadOnly() 개체와 모든 하위 요소에 대해 ConfigurationElementCollection 속성을 설정합니다.

(다음에서 상속됨 ConfigurationElementCollection)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)
Unmerge(ConfigurationElement, ConfigurationElement, ConfigurationSaveMode)

구성 계층 구조의 여러 수준에서 구성 정보를 병합한 결과를 되돌립니다.

(다음에서 상속됨 ConfigurationElementCollection)

명시적 인터페이스 구현

ICollection.CopyTo(Array, Int32)

ConfigurationElementCollection을 배열에 복사합니다.

(다음에서 상속됨 ConfigurationElementCollection)

확장 메서드

Cast<TResult>(IEnumerable)

IEnumerable의 요소를 지정된 형식으로 캐스팅합니다.

OfType<TResult>(IEnumerable)

지정된 형식에 따라 IEnumerable의 요소를 필터링합니다.

AsParallel(IEnumerable)

쿼리를 병렬화할 수 있도록 합니다.

AsQueryable(IEnumerable)

IEnumerableIQueryable로 변환합니다.

적용 대상

추가 정보