KeyValueConfigurationCollection 클래스
정의
KeyValueConfigurationElement 개체의 컬렉션을 포함합니다.Contains a collection of KeyValueConfigurationElement objects.
public ref class KeyValueConfigurationCollection : System::Configuration::ConfigurationElementCollection
[System.Configuration.ConfigurationCollection(typeof(System.Configuration.KeyValueConfigurationElement))]
public class KeyValueConfigurationCollection : System.Configuration.ConfigurationElementCollection
[System.Configuration.ConfigurationCollection(typeof(System.Configuration.KeyValueConfigurationElement), CollectionType=System.Configuration.ConfigurationElementCollectionType.AddRemoveClearMap)]
public class KeyValueConfigurationCollection : System.Configuration.ConfigurationElementCollection
[<System.Configuration.ConfigurationCollection(typeof(System.Configuration.KeyValueConfigurationElement))>]
type KeyValueConfigurationCollection = class
inherit ConfigurationElementCollection
[<System.Configuration.ConfigurationCollection(typeof(System.Configuration.KeyValueConfigurationElement), CollectionType=System.Configuration.ConfigurationElementCollectionType.AddRemoveClearMap)>]
type KeyValueConfigurationCollection = class
inherit ConfigurationElementCollection
Public Class KeyValueConfigurationCollection
Inherits ConfigurationElementCollection
- 상속
- 특성
예제
다음 코드 예제를 사용 하는 방법에 설명 합니다 KeyValueConfigurationCollection 형식입니다.The following code example demonstrates how to use the KeyValueConfigurationCollection type.
using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using System.Web;
using System.Web.Configuration;
namespace Samples.Aspnet.Config
{
class KeyValueConfigCollection
{
static void Main(string[] args)
{
try
{
// Set the path of the config file.
string configPath = "/aspnet";
// Get the Web application configuration object.
Configuration config =
WebConfigurationManager.OpenWebConfiguration(configPath);
// Get the section related object.
AppSettingsSection configSection =
(AppSettingsSection)config.GetSection
("appSettings");
// Display title and info.
Console.WriteLine("ASP.NET Configuration Info");
Console.WriteLine();
// Display Config details.
Console.WriteLine("File Path: {0}",
config.FilePath);
Console.WriteLine("Section Path: {0}",
configSection.SectionInformation.Name.ToString());
Console.WriteLine();
// Create the KeyValueConfigurationElement.
KeyValueConfigurationElement myAdminKeyVal =
new KeyValueConfigurationElement(
"myAdminTool", "admin.aspx");
// Determine if the configuration contains
// any KeyValueConfigurationElements.
KeyValueConfigurationCollection configSettings =
config.AppSettings.Settings;
if (configSettings.AllKeys.Length == 0)
{
// Add KeyValueConfigurationElement to collection.
config.AppSettings.Settings.Add(myAdminKeyVal);
if (!configSection.SectionInformation.IsLocked)
{
config.Save();
Console.WriteLine("** Configuration updated.");
}
else
{
Console.WriteLine("** Could not update, section is locked.");
}
}
// Get the KeyValueConfigurationCollection
// from the configuration.
KeyValueConfigurationCollection settings =
config.AppSettings.Settings;
// Display each KeyValueConfigurationElement.
foreach (KeyValueConfigurationElement keyValueElement in settings)
{
Console.WriteLine("Key: {0}", keyValueElement.Key);
Console.WriteLine("Value: {0}", keyValueElement.Value);
Console.WriteLine();
}
}
catch (Exception e)
{
// Unknown error.
Console.WriteLine(e.ToString());
}
// Display and wait
Console.ReadLine();
}
}
}
Imports System.Collections.Generic
Imports System.Text
Imports System.Configuration
Imports System.Web
Imports System.Web.Configuration
Namespace Samples.Aspnet.Config
Class KeyValueConfigCollection
Public Shared Sub Main()
Try
' Set the path of the config file.
Dim configPath As String = "/aspnet"
' Get the Web application configuration object.
Dim config As Configuration = _
WebConfigurationManager.OpenWebConfiguration(configPath)
' Get the section related object.
Dim configSection As System.Configuration.AppSettingsSection = _
CType(config.GetSection("appSettings"), System.Configuration.AppSettingsSection)
' Dim configSection As AppSettingsSection = _
' (AppSettingsSection)config.GetSection("appSettings")
' Display title and info.
Console.WriteLine("ASP.NET Configuration Info")
Console.WriteLine()
' Display Config details.
Console.WriteLine("File Path: {0}", config.FilePath)
Console.WriteLine("Section Path: {0}", _
configSection.SectionInformation.Name.ToString())
Console.WriteLine()
' Create the KeyValueConfigurationElement.
Dim myAdminKeyVal As KeyValueConfigurationElement = _
New KeyValueConfigurationElement _
("myAdminTool", "admin.aspx")
' Determine if the configuration contains
' any KeyValueConfigurationElements.
Dim configSettings As KeyValueConfigurationCollection = _
config.AppSettings.Settings()
If configSettings.AllKeys.Length = 0 Then
' Add KeyValueConfigurationElement to collection.
config.AppSettings.Settings.Add(myAdminKeyVal)
If Not configSection.SectionInformation.IsLocked Then
config.Save()
Console.WriteLine("** Configuration updated.")
Else
Console.WriteLine("** Could not update, section is locked.")
End If
End If
' Get the KeyValueConfigurationCollection
' from the configuration.
Dim settings As KeyValueConfigurationCollection = _
config.AppSettings.Settings()
' Display each KeyValueConfigurationElement.
Dim keyValueElement As KeyValueConfigurationElement
For Each keyValueElement In settings
Console.WriteLine("Key: {0}", keyValueElement.Key)
Console.WriteLine("Value: {0}", keyValueElement.Value)
Console.WriteLine()
Next
Catch e As System.ArgumentException
' Unknown error.
Console.WriteLine(e.ToString())
End Try
' Display and wait
Console.ReadLine()
End Sub
End Class
End Namespace
설명
이 클래스는 쌍의 컬렉션을 나타냅니다. 여기서 각 쌍은 컬렉션 키로 제공 되는 문자열과 문자열 값으로 구성 됩니다.This class represents a collection of pairs, where each pair consists of a string serving as a collection key and a string value. 첫 번째 요소는 키 이기 때문에 컬렉션에서 고유 해야 합니다.Because the first element is a key, it must be unique across the collection.
생성자
KeyValueConfigurationCollection() |
KeyValueConfigurationCollection 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the KeyValueConfigurationCollection class. |
속성
AddElementName |
파생 클래스에서 재정의될 때 ConfigurationElement의 추가 작업과 연결할 ConfigurationElementCollection의 이름을 가져오거나 설정합니다.Gets or sets the name of the ConfigurationElement to associate with the add operation in the ConfigurationElementCollection when overridden in a derived class. (다음에서 상속됨 ConfigurationElementCollection) |
AllKeys |
KeyValueConfigurationCollection 컬렉션에 포함된 모든 항목에 대한 키를 가져옵니다.Gets the keys to all items contained in the KeyValueConfigurationCollection collection. |
ClearElementName |
파생 클래스에서 재정의될 때 ConfigurationElement의 지우기 작업과 연결할 ConfigurationElementCollection의 이름을 가져오거나 설정합니다.Gets or sets the name for the ConfigurationElement to associate with the clear operation in the ConfigurationElementCollection when overridden in a derived class. (다음에서 상속됨 ConfigurationElementCollection) |
CollectionType |
ConfigurationElementCollection의 형식을 가져옵니다.Gets the type of the ConfigurationElementCollection. (다음에서 상속됨 ConfigurationElementCollection) |
Count |
컬렉션의 요소 수를 가져옵니다.Gets the number of elements in the collection. (다음에서 상속됨 ConfigurationElementCollection) |
CurrentConfiguration |
현재 Configuration 인스턴스가 속해 있는 구성 계층 구조를 나타내는 최상위 ConfigurationElement 인스턴스에 대한 참조를 가져옵니다.Gets a reference to the top-level Configuration instance that represents the configuration hierarchy that the current ConfigurationElement instance belongs to. (다음에서 상속됨 ConfigurationElement) |
ElementInformation |
ElementInformation 개체의 사용자 지정할 수 없는 정보와 기능을 포함하는 ConfigurationElement 개체를 가져옵니다.Gets an ElementInformation object that contains the non-customizable information and functionality of the ConfigurationElement object. (다음에서 상속됨 ConfigurationElement) |
ElementName |
파생 클래스에서 재정의될 때 구성 파일에서 이 요소 컬렉션을 식별하는 데 사용되는 이름을 가져옵니다.Gets the name used to identify this collection of elements in the configuration file when overridden in a derived class. (다음에서 상속됨 ConfigurationElementCollection) |
ElementProperty |
ConfigurationElementProperty 개체 자체를 나타내는 ConfigurationElement 개체를 가져옵니다.Gets the ConfigurationElementProperty object that represents the ConfigurationElement object itself. (다음에서 상속됨 ConfigurationElement) |
EmitClear |
컬렉션이 지워졌는지 여부를 지정하는 값을 가져오거나 설정합니다.Gets or sets a value that specifies whether the collection has been cleared. (다음에서 상속됨 ConfigurationElementCollection) |
EvaluationContext |
ContextInformation 개체의 ConfigurationElement 개체를 가져옵니다.Gets the ContextInformation object for the ConfigurationElement object. (다음에서 상속됨 ConfigurationElement) |
HasContext |
CurrentConfiguration 속성이 |
IsSynchronized |
컬렉션에 대한 액세스가 동기화되었는지 여부를 나타내는 값을 가져옵니다.Gets a value indicating whether access to the collection is synchronized. (다음에서 상속됨 ConfigurationElementCollection) |
Item[ConfigurationProperty] |
이 구성 요소의 속성이나 특성을 가져오거나 설정합니다.Gets or sets a property or attribute of this configuration element. (다음에서 상속됨 ConfigurationElement) |
Item[String] |
제공된 매개 변수를 기반으로 KeyValueConfigurationElement 개체를 가져옵니다.Gets the KeyValueConfigurationElement object based on the supplied parameter. |
LockAllAttributesExcept |
잠긴 특성의 컬렉션을 가져옵니다.Gets the collection of locked attributes. (다음에서 상속됨 ConfigurationElement) |
LockAllElementsExcept |
잠긴 요소의 컬렉션을 가져옵니다.Gets the collection of locked elements. (다음에서 상속됨 ConfigurationElement) |
LockAttributes |
잠긴 특성의 컬렉션을 가져옵니다.Gets the collection of locked attributes. (다음에서 상속됨 ConfigurationElement) |
LockElements |
잠긴 요소의 컬렉션을 가져옵니다.Gets the collection of locked elements. (다음에서 상속됨 ConfigurationElement) |
LockItem |
요소가 잠겨 있는지 여부를 나타내는 값을 가져오거나 설정합니다.Gets or sets a value indicating whether the element is locked. (다음에서 상속됨 ConfigurationElement) |
Properties |
구성 속성의 컬렉션을 가져옵니다.Gets a collection of configuration properties. |
RemoveElementName |
파생 클래스에서 재정의될 때 ConfigurationElement의 제거 작업과 연결할 ConfigurationElementCollection의 이름을 가져오거나 설정합니다.Gets or sets the name of the ConfigurationElement to associate with the remove operation in the ConfigurationElementCollection when overridden in a derived class. (다음에서 상속됨 ConfigurationElementCollection) |
SyncRoot |
ConfigurationElementCollection에 대한 액세스를 동기화하는 데 사용되는 개체를 가져옵니다.Gets an object used to synchronize access to the ConfigurationElementCollection. (다음에서 상속됨 ConfigurationElementCollection) |
ThrowOnDuplicate |
KeyValueConfigurationElement 컬렉션에 중복되는 KeyValueConfigurationCollection 개체를 추가하려고 하면 예외가 throw되는지 여부를 나타내는 값을 가져옵니다.Gets a value indicating whether an attempt to add a duplicate KeyValueConfigurationElement object to the KeyValueConfigurationCollection collection will cause an exception to be thrown. |
메서드
Add(KeyValueConfigurationElement) |
제공된 매개 변수를 기반으로 컬렉션에 KeyValueConfigurationElement 개체를 추가합니다.Adds a KeyValueConfigurationElement object to the collection based on the supplied parameters. |
Add(String, String) |
제공된 매개 변수를 기반으로 컬렉션에 KeyValueConfigurationElement 개체를 추가합니다.Adds a KeyValueConfigurationElement object to the collection based on the supplied parameters. |
BaseAdd(ConfigurationElement) |
구성 요소를 ConfigurationElementCollection에 추가합니다.Adds a configuration element to the ConfigurationElementCollection. (다음에서 상속됨 ConfigurationElementCollection) |
BaseAdd(ConfigurationElement, Boolean) |
구성 요소를 구성 요소 컬렉션에 추가합니다.Adds a configuration element to the configuration element collection. (다음에서 상속됨 ConfigurationElementCollection) |
BaseAdd(Int32, ConfigurationElement) |
구성 요소를 구성 요소 컬렉션에 추가합니다.Adds a configuration element to the configuration element collection. (다음에서 상속됨 ConfigurationElementCollection) |
BaseClear() |
컬렉션에서 구성 요소 개체를 모두 제거합니다.Removes all configuration element objects from the collection. (다음에서 상속됨 ConfigurationElementCollection) |
BaseGet(Int32) |
지정된 인덱스 위치에 있는 구성 요소를 가져옵니다.Gets the configuration element at the specified index location. (다음에서 상속됨 ConfigurationElementCollection) |
BaseGet(Object) |
지정된 키가 있는 구성 요소를 반환합니다.Returns the configuration element with the specified key. (다음에서 상속됨 ConfigurationElementCollection) |
BaseGetAllKeys() |
ConfigurationElementCollection에 포함된 모든 구성 요소의 키 배열을 반환합니다.Returns an array of the keys for all of the configuration elements contained in the ConfigurationElementCollection. (다음에서 상속됨 ConfigurationElementCollection) |
BaseGetKey(Int32) |
지정된 인덱스 위치에 있는 ConfigurationElement의 키를 가져옵니다.Gets the key for the ConfigurationElement at the specified index location. (다음에서 상속됨 ConfigurationElementCollection) |
BaseIndexOf(ConfigurationElement) |
지정된 ConfigurationElement의 인덱스를 나타냅니다.Indicates the index of the specified ConfigurationElement. (다음에서 상속됨 ConfigurationElementCollection) |
BaseIsRemoved(Object) |
지정된 키가 있는 ConfigurationElement가 ConfigurationElementCollection에서 제거되었는지 여부를 나타냅니다.Indicates whether the ConfigurationElement with the specified key has been removed from the ConfigurationElementCollection. (다음에서 상속됨 ConfigurationElementCollection) |
BaseRemove(Object) |
컬렉션에서 ConfigurationElement를 제거합니다.Removes a ConfigurationElement from the collection. (다음에서 상속됨 ConfigurationElementCollection) |
BaseRemoveAt(Int32) |
지정된 인덱스 위치에서 ConfigurationElement를 제거합니다.Removes the ConfigurationElement at the specified index location. (다음에서 상속됨 ConfigurationElementCollection) |
Clear() |
KeyValueConfigurationCollection 컬렉션을 지웁니다.Clears the KeyValueConfigurationCollection collection. |
CopyTo(ConfigurationElement[], Int32) |
ConfigurationElementCollection의 내용을 배열에 복사합니다.Copies the contents of the ConfigurationElementCollection to an array. (다음에서 상속됨 ConfigurationElementCollection) |
CreateNewElement() |
CreateNewElement() 메서드는 파생 클래스에서 재정의되는 경우 새 KeyValueConfigurationElement 개체를 만듭니다.When overridden in a derived class, the CreateNewElement() method creates a new KeyValueConfigurationElement object. |
CreateNewElement(String) |
파생 클래스에서 재정의될 때 새 ConfigurationElement를 만듭니다.Creates a new ConfigurationElement when overridden in a derived class. (다음에서 상속됨 ConfigurationElementCollection) |
DeserializeElement(XmlReader, Boolean) |
구성 파일에서 XML을 읽습니다.Reads XML from the configuration file. (다음에서 상속됨 ConfigurationElement) |
Equals(Object) |
ConfigurationElementCollection을 지정된 개체와 비교합니다.Compares the ConfigurationElementCollection to the specified object. (다음에서 상속됨 ConfigurationElementCollection) |
GetElementKey(ConfigurationElement) |
파생 클래스에서 재정의될 때 지정된 구성 요소의 요소 키를 가져옵니다.Gets the element key for a specified configuration element when overridden in a derived class. |
GetEnumerator() |
IEnumerator을 반복하는 데 사용되는 ConfigurationElementCollection를 가져옵니다.Gets an IEnumerator which is used to iterate through the ConfigurationElementCollection. (다음에서 상속됨 ConfigurationElementCollection) |
GetHashCode() |
ConfigurationElementCollection 인스턴스를 나타내는 고유 값을 가져옵니다.Gets a unique value representing the ConfigurationElementCollection instance. (다음에서 상속됨 ConfigurationElementCollection) |
GetTransformedAssemblyString(String) |
지정된 어셈블리 이름의 변환된 버전을 반환합니다.Returns the transformed version of the specified assembly name. (다음에서 상속됨 ConfigurationElement) |
GetTransformedTypeString(String) |
지정된 형식 이름의 변환된 버전을 반환합니다.Returns the transformed version of the specified type name. (다음에서 상속됨 ConfigurationElement) |
GetType() |
현재 인스턴스의 Type을 가져옵니다.Gets the Type of the current instance. (다음에서 상속됨 Object) |
Init() |
ConfigurationElement 개체를 초기 상태로 설정합니다.Sets the ConfigurationElement object to its initial state. (다음에서 상속됨 ConfigurationElement) |
InitializeDefault() |
ConfigurationElement 개체 값의 기본 집합을 초기화하는 데 사용됩니다.Used to initialize a default set of values for the ConfigurationElement object. (다음에서 상속됨 ConfigurationElement) |
IsElementName(String) |
지정된 ConfigurationElement가 ConfigurationElementCollection에 있는지 여부를 나타냅니다.Indicates whether the specified ConfigurationElement exists in the ConfigurationElementCollection. (다음에서 상속됨 ConfigurationElementCollection) |
IsElementRemovable(ConfigurationElement) |
지정한 ConfigurationElement를 ConfigurationElementCollection에서 제거할 수 있는지 여부를 나타냅니다.Indicates whether the specified ConfigurationElement can be removed from the ConfigurationElementCollection. (다음에서 상속됨 ConfigurationElementCollection) |
IsModified() |
파생 클래스에서 재정의될 때 이 ConfigurationElementCollection이 마지막으로 저장되거나 로드된 후 수정되었는지 여부를 나타냅니다.Indicates whether this ConfigurationElementCollection has been modified since it was last saved or loaded when overridden in a derived class. (다음에서 상속됨 ConfigurationElementCollection) |
IsReadOnly() |
ConfigurationElementCollection 개체가 읽기 전용인지 여부를 나타냅니다.Indicates whether the ConfigurationElementCollection object is read only. (다음에서 상속됨 ConfigurationElementCollection) |
ListErrors(IList) |
이 ConfigurationElement 개체와 모든 하위 요소의 잘못된 속성 오류를 전달된 목록에 추가합니다.Adds the invalid-property errors in this ConfigurationElement object, and in all subelements, to the passed list. (다음에서 상속됨 ConfigurationElement) |
MemberwiseClone() |
현재 Object의 단순 복사본을 만듭니다.Creates a shallow copy of the current Object. (다음에서 상속됨 Object) |
OnDeserializeUnrecognizedAttribute(String, String) |
역직렬화하는 동안 알 수 없는 특성을 발견했는지 여부를 나타내는 값을 가져옵니다.Gets a value indicating whether an unknown attribute is encountered during deserialization. (다음에서 상속됨 ConfigurationElement) |
OnDeserializeUnrecognizedElement(String, XmlReader) |
구성 시스템에서 예외를 throw하도록 합니다.Causes the configuration system to throw an exception. (다음에서 상속됨 ConfigurationElementCollection) |
OnRequiredPropertyNotFound(String) |
필수 속성이 없으면 예외를 throw합니다.Throws an exception when a required property is not found. (다음에서 상속됨 ConfigurationElement) |
PostDeserialize() |
deserialization 후에 호출됩니다.Called after deserialization. (다음에서 상속됨 ConfigurationElement) |
PreSerialize(XmlWriter) |
serialization 전에 호출됩니다.Called before serialization. (다음에서 상속됨 ConfigurationElement) |
Remove(String) |
컬렉션에서 KeyValueConfigurationElement 개체를 제거합니다.Removes a KeyValueConfigurationElement object from the collection. |
Reset(ConfigurationElement) |
파생 클래스에서 재정의될 때 ConfigurationElementCollection을 수정되지 않은 상태로 다시 설정합니다.Resets the ConfigurationElementCollection to its unmodified state when overridden in a derived class. (다음에서 상속됨 ConfigurationElementCollection) |
ResetModified() |
파생 클래스에서 재정의될 때 IsModified() 속성의 값을 |
SerializeElement(XmlWriter, Boolean) |
파생 클래스에서 재정의될 때 구성 파일의 XML 요소에 구성 데이터를 씁니다.Writes the configuration data to an XML element in the configuration file when overridden in a derived class. (다음에서 상속됨 ConfigurationElementCollection) |
SerializeToXmlElement(XmlWriter, String) |
파생 클래스에서 구현될 때 구성 요소의 외부 태그를 구성 파일에 씁니다.Writes the outer tags of this configuration element to the configuration file when implemented in a derived class. (다음에서 상속됨 ConfigurationElement) |
SetPropertyValue(ConfigurationProperty, Object, Boolean) |
속성을 지정된 값으로 설정합니다.Sets a property to the specified value. (다음에서 상속됨 ConfigurationElement) |
SetReadOnly() |
IsReadOnly() 개체와 모든 하위 요소에 대해 ConfigurationElementCollection 속성을 설정합니다.Sets the IsReadOnly() property for the ConfigurationElementCollection object and for all sub-elements. (다음에서 상속됨 ConfigurationElementCollection) |
ToString() |
현재 개체를 나타내는 문자열을 반환합니다.Returns a string that represents the current object. (다음에서 상속됨 Object) |
Unmerge(ConfigurationElement, ConfigurationElement, ConfigurationSaveMode) |
구성 계층 구조의 여러 수준에서 구성 정보를 병합한 결과를 되돌립니다.Reverses the effect of merging configuration information from different levels of the configuration hierarchy. (다음에서 상속됨 ConfigurationElementCollection) |
명시적 인터페이스 구현
ICollection.CopyTo(Array, Int32) |
ConfigurationElementCollection을 배열에 복사합니다.Copies the ConfigurationElementCollection to an array. (다음에서 상속됨 ConfigurationElementCollection) |
확장 메서드
Cast<TResult>(IEnumerable) |
IEnumerable의 요소를 지정된 형식으로 캐스팅합니다.Casts the elements of an IEnumerable to the specified type. |
OfType<TResult>(IEnumerable) |
지정된 형식에 따라 IEnumerable의 요소를 필터링합니다.Filters the elements of an IEnumerable based on a specified type. |
AsParallel(IEnumerable) |
쿼리를 병렬화할 수 있도록 합니다.Enables parallelization of a query. |
AsQueryable(IEnumerable) |
IEnumerable을 IQueryable로 변환합니다.Converts an IEnumerable to an IQueryable. |