AppDomain.GetData(String) Método
Definição
Obtém o valor armazenado no domínio atual do aplicativo para o nome especificado.Gets the value stored in the current application domain for the specified name.
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
Parâmetros
- name
- String
O nome de uma propriedade de domínio de aplicativo predefinida ou o nome de uma propriedade de domínio de aplicativo que você definiu.The name of a predefined application domain property, or the name of an application domain property you have defined.
Retornos
O valor da propriedade name ou null se a propriedade não existir.The value of the name property, or null if the property does not exist.
Implementações
Exceções
name é null.name is null.
A operação é tentada em um domínio de aplicativo descarregado.The operation is attempted on an unloaded application domain.
Exemplos
O exemplo a seguir cria um novo domínio de aplicativo, define um valor fornecido pelo sistema para o domínio e adiciona um novo par de valor para o domínio.The following example creates a new application domain, sets a system-provided value for the domain, and adds a new value pair for the domain. Em seguida, o exemplo demonstra como usar o GetData método para recuperar os dados desses pares de valor e exibi-los para o console.The example then demonstrates how to use the GetData method to retrieve the data from these value pairs and display them to the 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
*/
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
Comentários
Use esse método para recuperar o valor de uma entrada em um cache interno de pares de dados de nome que descrevem as propriedades dessa instância do AppDomain .Use this method to retrieve the value of an entry in an internal cache of name-data pairs that describe properties of this instance of AppDomain. Observe que a comparação de name com o nome dos pares chave-valor diferencia maiúsculas de minúsculas.Note that the comparison of name with the name of key-value pairs is case-sensitive.
O cache contém automaticamente as entradas de sistema predefinidas que são inseridas quando o domínio do aplicativo é criado.The cache automatically contains predefined system entries that are inserted when the application domain is created. Você pode inspecionar seus valores com o GetData método ou as propriedades equivalentes AppDomainSetup .You can inspect their values with the GetData method, or the equivalent AppDomainSetup properties.
Você pode inserir ou modificar seus próprios pares de dados de nome definidos pelo usuário com o SetData método e inspecionar seus valores com o GetData método.You can insert or modify your own user defined name-data pairs with the SetData method and inspect their values with the GetData method.
A tabela a seguir descreve o name de cada entrada de sistema predefinida e sua AppDomainSetup propriedade correspondente.The following table describes the name of each predefined system entry and its corresponding AppDomainSetup property.
| Valor de ' name 'Value of 'name' | PropriedadeProperty |
|---|---|
| APPBASE"APPBASE" | AppDomainSetup.ApplicationBase |
| "APP_CONFIG_FILE""APP_CONFIG_FILE" | AppDomainSetup.ConfigurationFile |
| "APP_LAUNCH_URL""APP_LAUNCH_URL" | (nenhuma propriedade)(no property) "APP_LAUNCH_URL" representa a URL solicitada originalmente pelo usuário, antes de qualquer redirecionamento."APP_LAUNCH_URL" represents the URL originally requested by the user, before any redirection. Ele está disponível somente quando o aplicativo foi iniciado com um navegador, como o Internet Explorer.It is available only when the application has been launched with a browser such as Internet Explorer. Nem todos os navegadores fornecem esse valor.Not all browsers provide this value. |
| "APP_NAME""APP_NAME" | AppDomainSetup.ApplicationName |
| "BINPATH_PROBE_ONLY""BINPATH_PROBE_ONLY" | AppDomainSetup.PrivateBinPathProbe |
| "CACHE_BASE""CACHE_BASE" | AppDomainSetup.CachePath |
| "CODE_DOWNLOAD_DISABLED""CODE_DOWNLOAD_DISABLED" | AppDomainSetup.DisallowCodeDownload |
| "DEV_PATH""DEV_PATH" | (nenhuma propriedade)(no property) |
| "DISALLOW_APP""DISALLOW_APP" | AppDomainSetup.DisallowPublisherPolicy |
| "DISALLOW_APP_BASE_PROBING""DISALLOW_APP_BASE_PROBING" | AppDomainSetup.DisallowApplicationBaseProbing |
| "DISALLOW_APP_REDIRECTS""DISALLOW_APP_REDIRECTS" | AppDomainSetup.DisallowBindingRedirects |
| "DYNAMIC_BASE""DYNAMIC_BASE" | AppDomainSetup.DynamicBase |
| "FORCE_CACHE_INSTALL""FORCE_CACHE_INSTALL" | AppDomainSetup.ShadowCopyFiles |
| "LICENSE_FILE" ou uma cadeia de caracteres específica do aplicativo"LICENSE_FILE", or an application-specific string | AppDomainSetup.LicenseFile |
| "LOADER_OPTIMIZATION""LOADER_OPTIMIZATION" | AppDomainSetup.LoaderOptimization |
| "LOCATION_URI""LOCATION_URI" | (nenhuma propriedade)(no property) |
| "PRIVATE_BINPATH""PRIVATE_BINPATH" | AppDomainSetup.PrivateBinPath |
| "REGEX_DEFAULT_MATCH_TIMEOUT""REGEX_DEFAULT_MATCH_TIMEOUT" | Regex.MatchTimeout "REGEX_DEFAULT_MATCH_TIMEOUT" não é uma entrada do sistema e seu valor pode ser definido chamando o SetData método."REGEX_DEFAULT_MATCH_TIMEOUT" is not a system entry, and its value can be set by calling the SetData method. |
| "SHADOW_COPY_DIRS""SHADOW_COPY_DIRS" | AppDomainSetup.ShadowCopyDirectories |