ContextInformation 클래스

정의

ConfigurationElement 개체와 연결된 컨텍스트 정보를 캡슐화합니다. 이 클래스는 상속될 수 없습니다.

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

예제

다음 코드 예제를 사용 하는 방법에 설명 합니다 ContextInformation 형식입니다.

#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.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 구성 요소와 관련된 환경 세부 정보를 제공합니다. instance 경우 속성을 사용하여 IsMachineLevel 가 Machine.config 설정되었는지 여부를 ConfigurationElement 확인하거나 속성을 사용하여 HostingContext 가 속한 계층 구조를 ConfigurationElement 확인할 수 있습니다.

속성

HostingContext

구성 속성이 확인되는 환경의 컨텍스트를 가져옵니다.

IsMachineLevel

구성 속성이 컴퓨터 구성 수준에서 확인되는지 여부를 지정하는 값을 가져옵니다.

메서드

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

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

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetSection(String)

지정된 섹션 이름에 따라 구성 섹션 정보를 포함하는 개체를 제공합니다.

GetType()

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

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

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

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

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

(다음에서 상속됨 Object)

적용 대상