AppDomain.GetData(String) Metodo

Definizione

Ottiene il valore archiviato nel dominio applicazione attuale per il nome specificato.

public:
 System::Object ^ GetData(System::String ^ name);
public:
 virtual System::Object ^ GetData(System::String ^ name);
public object? GetData (string name);
public object GetData (string name);
member this.GetData : string -> obj
abstract member GetData : string -> obj
override this.GetData : string -> obj
Public Function GetData (name As String) As Object

Parametri

name
String

Nome di una proprietà del dominio applicazione predefinita o nome della proprietà di un dominio applicazione definito.

Restituisce

Valore della proprietà name oppure null se la proprietà non esiste.

Implementazioni

Eccezioni

name è null.

L'operazione viene tentata in un dominio dell'applicazione non caricato.

Esempio

Nell'esempio seguente viene creato un nuovo dominio applicazione, viene impostato un valore fornito dal sistema per il dominio e viene aggiunta una nuova coppia di valori per il dominio. L'esempio illustra quindi come usare il GetData metodo per recuperare i dati da queste coppie di valori e visualizzarli nella console.

using namespace System;
using namespace System::Reflection;

int main()
{
   // appdomain setup information
   AppDomain^ currentDomain = AppDomain::CurrentDomain;
   
   //Create a new value pair for the appdomain
   currentDomain->SetData( "ADVALUE", "Example value" );
   
   //get the value specified in the setdata method
   Console::WriteLine( "ADVALUE is: {0}", currentDomain->GetData( "ADVALUE" ) );
   
   //get a system value specified at appdomainsetup
   Console::WriteLine( "System value for loader optimization: {0}", 
      currentDomain->GetData( "LOADER_OPTIMIZATION" ) );
}

/* This code example produces the following output:

ADVALUE is: Example value
System value for loader optimization: NotSpecified
 */
using System;
using System.Reflection;

class ADGetData
{
    public static void Main()
    {
        // appdomain setup information
        AppDomain currentDomain = AppDomain.CurrentDomain;

        //Create a new value pair for the appdomain
        currentDomain.SetData("ADVALUE", "Example value");

        //get the value specified in the setdata method
        Console.WriteLine("ADVALUE is: " + currentDomain.GetData("ADVALUE"));

        //get a system value specified at appdomainsetup
        Console.WriteLine("System value for loader optimization: {0}",
            currentDomain.GetData("LOADER_OPTIMIZATION"));
    }
}

/* This code example produces the following output:

ADVALUE is: Example value
System value for loader optimization: NotSpecified
 */
open System

// appdomain setup information
let currentDomain = AppDomain.CurrentDomain

//Create a new value pair for the appdomain
currentDomain.SetData("ADVALUE", "Example value")

//get the value specified in the setdata method
currentDomain.GetData "ADVALUE"
|> printfn "ADVALUE is: %O"

//get a system value specified at appdomainsetup
currentDomain.GetData "LOADER_OPTIMIZATION"
|> printfn "System value for loader optimization: %O"

(* This code example produces the following output:

ADVALUE is: Example value
System value for loader optimization: NotSpecified
*)
Imports System.Reflection

Class ADGetData   
   
   Public Shared Sub Main()
      ' appdomain setup information
      Dim currentDomain As AppDomain = AppDomain.CurrentDomain
      
      'Create a new value pair for the appdomain
      currentDomain.SetData("ADVALUE", "Example value")
      
      'get the value specified in the setdata method
      Console.WriteLine(("ADVALUE is: " & currentDomain.GetData("ADVALUE")))
      
      'get a system value specified at appdomainsetup
      Console.WriteLine("System value for loader optimization: {0}", _
         currentDomain.GetData("LOADER_OPTIMIZATION"))

   End Sub 
End Class 

' This code example produces the following output:
'
'ADVALUE is: Example value
'System value for loader optimization: NotSpecified

Commenti

Usare questo metodo per recuperare il valore di una voce in una cache interna di coppie nome-dati che descrivono le proprietà di questa istanza di AppDomain. Si noti che il confronto tra name con il nome delle coppie chiave-valore è distinzione tra maiuscole e minuscole.

La cache contiene automaticamente voci di sistema predefinite inserite quando viene creato il dominio dell'applicazione. È possibile controllare i valori con il GetData metodo o le proprietà equivalenti AppDomainSetup .

È possibile inserire o modificare le coppie nome-dati definite dall'utente con il SetData metodo e controllare i valori con il GetData metodo .

La tabella seguente descrive la voce predefinita del sistema e la name relativa proprietà corrispondente AppDomainSetup .

Valore di 'name' Proprietà
"APPBASE" AppDomainSetup.ApplicationBase
"APP_CONFIG_FILE" AppDomainSetup.ConfigurationFile
"APP_LAUNCH_URL" (nessuna proprietà)

"APP_LAUNCH_URL" rappresenta l'URL originariamente richiesto dall'utente, prima di qualsiasi reindirizzamento. È disponibile solo quando l'applicazione è stata avviata con un browser. Non tutti i browser forniscono questo valore.
"APP_NAME" AppDomainSetup.ApplicationName
"BINPATH_PROBE_ONLY" AppDomainSetup.PrivateBinPathProbe
"CACHE_BASE" AppDomainSetup.CachePath
"CODE_DOWNLOAD_DISABLED" AppDomainSetup.DisallowCodeDownload
"DEV_PATH" (nessuna proprietà)
"DISALLOW_APP" AppDomainSetup.DisallowPublisherPolicy
"DISALLOW_APP_BASE_PROBING" AppDomainSetup.DisallowApplicationBaseProbing
"DISALLOW_APP_REDIRECTS" AppDomainSetup.DisallowBindingRedirects
"DYNAMIC_BASE" AppDomainSetup.DynamicBase
"FORCE_CACHE_INSTALL" AppDomainSetup.ShadowCopyFiles
"LICENSE_FILE" o una stringa specifica dell'applicazione AppDomainSetup.LicenseFile
"LOADER_OPTIMIZATION" AppDomainSetup.LoaderOptimization
"LOCATION_URI" (nessuna proprietà)
"PRIVATE_BINPATH" AppDomainSetup.PrivateBinPath
"REGEX_DEFAULT_MATCH_TIMEOUT" Regex.MatchTimeout

"REGEX_DEFAULT_MATCH_TIMEOUT" non è una voce di sistema e il relativo valore può essere impostato chiamando il SetData metodo.
"SHADOW_COPY_DIRS" AppDomainSetup.ShadowCopyDirectories

Si applica a

Vedi anche