ContextInformationとは? わかりやすく解説

ContextInformation クラス

メモ : このクラスは、.NET Framework version 2.0新しく追加されたものです。

ConfigurationElement オブジェクト関連付けられているコンテキスト情報カプセル化ます。このクラス継承できません。

名前空間: System.Configuration
アセンブリ: System.Configuration (system.configuration.dll 内)
構文構文

Public NotInheritable Class
 ContextInformation
Dim instance As ContextInformation
public sealed class ContextInformation
public ref class ContextInformation sealed
public final class ContextInformation
public final class ContextInformation
解説解説

ContextInformation オブジェクトは、構成要素関連する環境詳細情報提供します。たとえば、IsMachineLevel プロパティ使用して ConfigurationElement が Machine.config で設定されたのかどうか確認したり、HostingContext プロパティ使用して ConfigurationElement属す階層確認したできます

使用例使用例

ContextInformation 型を使用する方法次のコード例示します

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
#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();
    }
  }
}
継承階層継承階層
System.Object
  System.Configuration.ContextInformation
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

ContextInformation プロパティ


ContextInformation メソッド


パブリック メソッドパブリック メソッド

プロテクト メソッドプロテクト メソッド
参照参照

関連項目

ContextInformation クラス
System.Configuration 名前空間

ContextInformation メンバ

ConfigurationElement オブジェクト関連付けられているコンテキスト情報カプセル化ます。このクラス継承できません。

ContextInformation データ型公開されるメンバを以下の表に示します


パブリック プロパティパブリック プロパティ
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

ContextInformation クラス
System.Configuration 名前空間


このページでは「.NET Framework クラス ライブラリ リファレンス」からContextInformationを検索した結果を表示しています。
Weblioに収録されているすべての辞書からContextInformationを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からContextInformationを検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「ContextInformation」の関連用語

ContextInformationのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ContextInformationのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS