ConfigurationSection.GetRuntimeObject Metodo

Definizione

Restituisce un oggetto personalizzato quando ne viene eseguito l'override in una classe derivata.

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

Restituisce

Oggetto che rappresenta la sezione.

Esempio

Nell'esempio seguente viene illustrato come utilizzare il metodo 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

Commenti

Quando il GetSection metodo viene chiamato in fase di esecuzione, il sistema di configurazione crea prima un'istanza appropriata della ConfigurationSection classe e quindi restituisce l'oggetto ottenuto dal GetRuntimeObject metodo .

Per impostazione predefinita, GetRuntimeObject restituisce semplicemente l'oggetto che rappresenta l'oggetto ConfigurationSection da cui viene chiamato.

Note per gli eredi

È possibile eseguire l'override del GetRuntimeObject() metodo per restituire un tipo personalizzato in fase di esecuzione.

Ad esempio, per limitare la modifica di runtime delle impostazioni della classe, è possibile eseguire l'override ConfigurationSectionGetRuntimeObject() e restituire un tipo personalizzato che applica restrizioni per cui è possibile modificare le impostazioni, se presente.

Se l'oggetto runtime è interno solo, l'oggetto restituito non può essere usato all'esterno dell'assembly che lo definisce. Un modo per creare un oggetto che deriva da ConfigurationSection e può essere accessibile solo dal codice nell'assembly in fase di esecuzione consiste nel creare un oggetto runtime interno con un metodo che restituisce l'implementazione ConfigurationSection .

Si applica a