ConfigurationBuilder 클래스
정의
사용자 지정 구성 작성기 구현으로 확장될 기본 클래스를 나타냅니다.Represents the base class to be extended by custom configuration builder implementations.
public ref class ConfigurationBuilder abstract : System::Configuration::Provider::ProviderBase
public abstract class ConfigurationBuilder : System.Configuration.Provider.ProviderBase
type ConfigurationBuilder = class
inherit ProviderBase
Public MustInherit Class ConfigurationBuilder
Inherits ProviderBase
- 상속
예제
다음 예제에서는 환경 변수를 읽을 간단한 ConfigurationBuilder를 구현 하는 방법을 보여 줍니다.The following example shows how to implement a simple ConfigurationBuilder to read Environment variables:
using System;
using System.Configuration;
using System.Xml;
namespace Samples.AspNet.Config
{
public class SampleConfigurationBuilder : ConfigurationBuilder
{
public override XmlNode ProcessRawXml(XmlNode rawXml)
{
string rawXmlString = rawXml.OuterXml;
if (String.IsNullOrEmpty(rawXmlString)) {
return rawXml;
}
rawXmlString = Environment.ExpandEnvironmentVariables(rawXmlString);
XmlDocument doc = new XmlDocument();
doc.PreserveWhitespace = true;
doc.LoadXml(rawXmlString);
return doc.DocumentElement;
}
public override ConfigurationSection ProcessConfigurationSection(ConfigurationSection configSection)
=> configSection;
}
}
Imports System.Configuration
Imports System.Xml
Public Class SampleConfigurationBuilder : Inherits ConfigurationBuilder
Public Overrides Function ProcessRawXml(rawXml As XmlNode) As XmlNode
Dim rawXmlString As String = rawXml.OuterXml
If String.IsNullOrEmpty(rawXmlString) Then
Return rawXml
End If
rawXmlString = Environment.ExpandEnvironmentVariables(rawXmlString)
Dim doc As New XmlDocument()
doc.PreserveWhitespace = True
doc.LoadXml(rawXmlString)
Return doc.DocumentElement
End Function
Public Overrides Function ProcessConfigurationSection(configSection As ConfigurationSection) As ConfigurationSection
Return configSection
End Function
End Class
다음 예제에서는 구성 파일의 일부는 앞의 예제에 적용 됩니다.The following example is an excerpt of the configuration file as it applies to the previous example. AppSettings 구성에 환경 변수를 적용 하 고 해당 값에서 가능이 ConfigurationManager.AppSettings합니다.This applies environment variables to the appSettings configuration and makes those values available under ConfigurationManager.AppSettings.
<!-- To declare and use Configuration Builders in your configuration chain, update your app.config or web.config file as follows: -->
<configSections>
<section name="configBuilders" type="System.Configuration.ConfigurationBuildersSection, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" restartOnExternalChanges="false" requirePermission="false"/>
</configSections>
<configBuilders>
<builders>
<add name="SampleConfigurationBuilder" type="CustomConfigBuilders.MyConfigBuilder, CustomConfigBuilders" />
</builders>
</configBuilders>
<!-- To apply Configuration Builders to a configuration section, use the 'configBuilders' tag as follows: -->
<appSettings configBuilders="SampleConfigurationBuilder">
<add key="COMPUTERNAME" value="Will Be Replaced by EnvironmentVariable" />
</appSettings>
설명
표준을 사용 하 여.NET Framework 애플리케이션에서 사용 하려는 외부 원본에서 구성을 읽을 수 있는이 클래스에서 파생 ConfigurationManager API.Derive from this class to read configuration from an external source that you would like to consume in your .NET Framework application using the standard ConfigurationManager API. ConfigurationBuilders 환경 변수, Azure key vault 및 다양 한 다른 원본에서 읽을 수는 NuGet.org에서 사용할 수 있습니다.ConfigurationBuilders are available on NuGet.org to read from environment variables, Azure key vault, and a number of other sources.
여러 구현의 ConfigurationBuilders NuGet.org에서 사용할 수 있습니다.Several implementations of ConfigurationBuilders are available from NuGet.org:
- 환경 Configbuilder -환경 변수에서 읽습니다.EnvironmentConfigBuilder - Read from environment variables.
- AzureKeyVaultConfigBuilder -Azure Key Vault에서 읽습니다.AzureKeyVaultConfigBuilder - Read from Azure Key Vault.
- UserSecretsConfigBuilder -디스크의 usersecrets 파일을 읽고 ASP.NET Core 기능과 비슷합니다.UserSecretsConfigBuilder - Read from a usersecrets file on disk, similar to the ASP.NET Core functionality.
- SimpleJsonConfigBuilder -JSON 파일에서 읽습니다.SimpleJsonConfigBuilder - Read from a JSON file.
생성자
ConfigurationBuilder() |
ConfigurationBuilder 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the ConfigurationBuilder class. |
속성
Description |
관리 도구나 다른 UI(사용자 인터페이스)에 표시하기에 적합한 간단하고 이해하기 쉬운 설명을 가져옵니다.Gets a brief, friendly description suitable for display in administrative tools or other user interfaces (UIs). (다음에서 상속됨 ProviderBase) |
Name |
구성 중 공급자를 참조하는 데 사용되는 이름을 가져옵니다.Gets the friendly name used to refer to the provider during configuration. (다음에서 상속됨 ProviderBase) |
메서드
Equals(Object) |
지정된 개체가 현재 개체와 같은지 확인합니다.Determines whether the specified object is equal to the current object. (다음에서 상속됨 Object) |
GetHashCode() |
기본 해시 함수로 작동합니다.Serves as the default hash function. (다음에서 상속됨 Object) |
GetType() |
현재 인스턴스의 Type을 가져옵니다.Gets the Type of the current instance. (다음에서 상속됨 Object) |
Initialize(String, NameValueCollection) |
구성 작성기를 초기화합니다.Initializes the configuration builder. (다음에서 상속됨 ProviderBase) |
MemberwiseClone() |
현재 Object의 단순 복사본을 만듭니다.Creates a shallow copy of the current Object. (다음에서 상속됨 Object) |
ProcessConfigurationSection(ConfigurationSection) |
구성 시스템의 ConfigurationSection 개체를 허용하고 나중에 사용하기 위해 수정되거나 새로운 ConfigurationSection개체를 반환합니다.Accepts a ConfigurationSection object from the configuration system and returns a modified or new ConfigurationSection object for further use. |
ProcessRawXml(XmlNode) |
구성 파일의 원시 구성 섹션을 나타내는 XmlNode를 허용하고 나중에 사용할 수 있도록 수정되거나 새로운 XmlNode를 반환합니다.Accepts an XmlNode representing the raw configuration section from a config file and returns a modified or new XmlNode for further use. |
ToString() |
현재 개체를 나타내는 문자열을 반환합니다.Returns a string that represents the current object. (다음에서 상속됨 Object) |