ConfigurationSection.GetRuntimeObject Metodo

Definizione

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

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

Valori restituiti

Oggetto che rappresenta la sezione.

Esempio

Nell'esempio seguente viene illustrato come usare il GetRuntimeObject metodo .

// 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 innanzitutto 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 in fase di esecuzione delle impostazioni nella ConfigurationSection classe , è possibile eseguire l'override GetRuntimeObject() e restituire un tipo personalizzato che applica restrizioni sulle impostazioni che possono essere modificate, se presenti.

Se l'oggetto runtime è solo interno, l'oggetto restituito non può essere utilizzato 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