ConfigurationSection.GetRuntimeObject メソッド

定義

派生クラスでオーバーライドされると、カスタム オブジェクトを返します。

protected public:
 virtual System::Object ^ GetRuntimeObject();
protected internal virtual object GetRuntimeObject();
abstract member GetRuntimeObject : unit -> obj
override this.GetRuntimeObject : unit -> obj
Protected Friend Overridable Function GetRuntimeObject () As Object

返品

セクションを表すオブジェクト。

次の例は、 GetRuntimeObject メソッドの使用方法を示しています。

// Customizes the use of CustomSection
// by setting _ReadOnly to false.
// Remember you must use it along with ThrowIfReadOnly.
protected override object GetRuntimeObject()
{
    // To enable property setting just assign true to
    // the following flag.
    _ReadOnly = true;
    return base.GetRuntimeObject();
}
' Customizes the use of CustomSection
 ' by setting _ReadOnly to false.
' Remember you must use it along with ThrowIfReadOnly.
Protected Overrides Function GetRuntimeObject() As Object
   ' To enable property setting just assign true to
   ' the following flag.
   _ReadOnly = True
   Return MyBase.GetRuntimeObject()
End Function 'GetRuntimeObject

注釈

GetSection メソッドが実行時に呼び出されると、構成システムは最初に ConfigurationSection クラスの適切なインスタンスを作成し、GetRuntimeObject メソッドから取得したオブジェクトを返します。

既定では、 GetRuntimeObject は呼び出し元の ConfigurationSection を表すオブジェクトを単に返します。

注意 (継承者)

GetRuntimeObject() メソッドをオーバーライドして、実行時にカスタム型を返すことができます。

たとえば、 ConfigurationSection クラスの設定のランタイム変更を制限するには、 GetRuntimeObject() をオーバーライドし、変更できる設定 (ある場合) に制限を適用するカスタム型を返します。

ランタイム オブジェクトが内部オブジェクトのみである場合、返されるオブジェクトは、それを定義するアセンブリの外部では使用できません。 ConfigurationSectionから派生し、実行時にアセンブリ内のコードによってのみアクセスできるオブジェクトを作成する 1 つの方法は、ConfigurationSection実装を返すメソッドを持つ内部ランタイム オブジェクトを作成することです。

適用対象