ConfigurationSection.GetRuntimeObject 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
在派生类中重写时返回自定义对象。
protected public:
virtual System::Object ^ GetRuntimeObject();
protected:
virtual System::Object ^ GetRuntimeObject();
protected internal virtual object GetRuntimeObject();
protected virtual object GetRuntimeObject();
abstract member GetRuntimeObject : unit -> obj
override this.GetRuntimeObject : unit -> obj
Protected Friend Overridable Function GetRuntimeObject () As Object
Protected 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 自且只能在运行时通过程序集中的代码访问的对象的一种方法是创建一个内部运行时对象,该对象具有返回 ConfigurationSection 实现的方法。