ContextInformation ContextInformation ContextInformation ContextInformation Class

정의

ConfigurationElement 개체와 연결된 컨텍스트 정보를 캡슐화합니다.Encapsulates the context information that is associated with a ConfigurationElement object. 이 클래스는 상속될 수 없습니다.This class cannot be inherited.

public ref class ContextInformation sealed
public sealed class ContextInformation
type ContextInformation = class
Public NotInheritable Class ContextInformation
상속
ContextInformationContextInformationContextInformationContextInformation

예제

다음 코드 예제를 사용 하는 방법에 설명 합니다 ContextInformation 형식입니다.The following code example demonstrates how to use the ContextInformation type.

#region Using directives

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

#endregion

namespace Samples.Aspnet.ConfigurationSample
{
  class UsingContextInformation
  {
    static void Main(string[] args)
    {
      try
      {
        // Set the path of the config file.
        string configPath = "";

        // Get the Web application configuration object.
        Configuration config = WebConfigurationManager.OpenWebConfiguration(configPath);

        // Get the section related object.
        HealthMonitoringSection configSection =
          (HealthMonitoringSection)config.GetSection("system.web/healthMonitoring");

        // 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);

          // IsMachineLevel property.
          Console.WriteLine("IsMachineLevel: {0}",
            config.EvaluationContext.IsMachineLevel);

          // Create an object based on HostingContext.
          WebContext myWC =
            (WebContext)config.EvaluationContext.HostingContext;
          // Use the WebContext object to determine
          // the ApplicationLevel.
          Console.WriteLine("ApplicationLevel: {0}",
            myWC.ApplicationLevel);
        }

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

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

Namespace Samples.Aspnet.ConfigurationSample
  Class UsingContextInformation
    Public Shared Sub Main()
      Try
        ' Set the path of the config file.
        Dim configPath As String = ""

        ' Get the Web application configuration object.
        Dim config As Configuration = _
            WebConfigurationManager.OpenWebConfiguration(configPath)

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

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

        ' IsMachineLevel property.
        Console.WriteLine("IsMachineLevel: {0}", _
          config.EvaluationContext.IsMachineLevel)

        ' Create an object based on HostingContext.
        Dim myWC As WebContext = _
          config.EvaluationContext.HostingContext
        ' Use the WebContext object to determine
        ' the ApplicationLevel.
        Console.WriteLine("ApplicationLevel: {0}", _
          myWC.ApplicationLevel)

      Catch e As System.Exception
        ' Error.
        Console.WriteLine(e.ToString())
      End Try
      ' Display and wait.
      Console.ReadLine()
    End Sub
  End Class
End Namespace

설명

ContextInformation 개체는 구성 요소와 관련 된 환경 세부 정보를 제공 합니다.The ContextInformation object provides environment details related to an element of the configuration. 예를 들어 사용할 수 있습니다는 IsMachineLevel 속성을 여부를 ConfigurationElement Machine.config에 설정 된 또는 계층 구조를 확인할 수 있습니다를 ConfigurationElement 사용 하 여 속한를 HostingContext 속성입니다.For instance, you can use the IsMachineLevel property to determine whether a ConfigurationElement was set in Machine.config, or you can determine which hierarchy a ConfigurationElement belongs to by using the HostingContext property.

속성

HostingContext HostingContext HostingContext HostingContext

구성 속성이 확인되는 환경의 컨텍스트를 가져옵니다.Gets the context of the environment where the configuration property is being evaluated.

IsMachineLevel IsMachineLevel IsMachineLevel IsMachineLevel

구성 속성이 컴퓨터 구성 수준에서 확인되는지 여부를 지정하는 값을 가져옵니다.Gets a value specifying whether the configuration property is being evaluated at the machine configuration level.

메서드

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

지정한 개체와 현재 개체가 같은지 여부를 확인합니다.Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

기본 해시 함수로 작동합니다.Serves as the default hash function.

(Inherited from Object)
GetSection(String) GetSection(String) GetSection(String) GetSection(String)

지정된 섹션 이름에 따라 구성 섹션 정보를 포함하는 개체를 제공합니다.Provides an object containing configuration-section information based on the specified section name.

GetType() GetType() GetType() GetType()

현재 인스턴스의 Type을 가져옵니다.Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

현재 개체를 나타내는 문자열을 반환합니다.Returns a string that represents the current object.

(Inherited from Object)

적용 대상