ConfigurationSection.GetRuntimeObject Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Returns a custom object when overridden in a derived class.
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
Returns
The object representing the section.
Examples
The following example shows how to use the GetRuntimeObject method.
// 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
Remarks
When the GetSection method is called at run time, the configuration system first creates an appropriate instance of the ConfigurationSection class, and then returns the object it obtains from the GetRuntimeObject method.
By default, GetRuntimeObject simply returns the object that represents the ConfigurationSection from which it is called.
Notes to Inheritors
You can override the GetRuntimeObject() method to return a custom type at run time.
For example, to restrict runtime modification of the settings in the ConfigurationSection class, you can override GetRuntimeObject() and return a custom type that enforces restrictions on which settings can be modified, if any.
If the runtime object is internal only, the returned object cannot be used outside the assembly that defines it. One way to create an object that derives from ConfigurationSection and can only be accessed by code in your assembly at run time is to create an internal runtime object that has a method that returns your ConfigurationSection implementation.