AppDomain.SetData メソッド
定義
アプリケーション ドメイン プロパティに値を代入します。Assigns a value to an application domain property.
オーバーロード
SetData(String, Object) |
指定したアプリケーション ドメイン プロパティに、指定した値を割り当てます。Assigns the specified value to the specified application domain property. |
SetData(String, Object, IPermission) |
アプリケーション ドメインの特定のプロパティに対し、指定された値を代入します。プロパティの取得時に呼び出し元に要求するアクセス許可を引数として受け取ります。Assigns the specified value to the specified application domain property, with a specified permission to demand of the caller when the property is retrieved. |
SetData(String, Object)
指定したアプリケーション ドメイン プロパティに、指定した値を割り当てます。Assigns the specified value to the specified application domain property.
public:
virtual void SetData(System::String ^ name, System::Object ^ data);
[System.Security.SecurityCritical]
public void SetData (string name, object data);
abstract member SetData : string * obj -> unit
override this.SetData : string * obj -> unit
Public Sub SetData (name As String, data As Object)
パラメーター
- name
- String
作成または変更の対象となるユーザー定義アプリケーション ドメイン プロパティの名前。The name of a user-defined application domain property to create or change.
- data
- Object
プロパティの値。The value of the property.
実装
- 属性
例外
アンロードされたアプリケーション ドメインで操作しようとします。The operation is attempted on an unloaded application domain.
例
次の例では、SetData(String, Object) メソッドを使用して、新しい値のペアを作成する方法を示します。The following example demonstrates how to use the SetData(String, Object) method to create a new value pair. この例では、GetData メソッドを使用して値を取得し、コンソールに表示します。The example then uses the GetData method to retrieve the value, and displays it 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
注釈
このメソッドを使用してエントリを挿入するか、AppDomainのこのインスタンスのプロパティを記述する名前とデータのペアの内部キャッシュにあるエントリの値を変更します。Use this method to insert an entry, or modify the value of an entry in an internal cache of name-data pairs that describe properties of this instance of AppDomain.
キャッシュには、アプリケーションドメインの作成時に挿入される定義済みのシステムエントリが自動的に含まれます。The cache automatically contains predefined system entries that are inserted when the application domain is created. このメソッドでシステムエントリを挿入または変更することはできません。You cannot insert or modify system entries with this method. システムエントリを変更しようとするメソッド呼び出しは効果がありません。メソッドは例外をスローしません。A method call that attempts to modify a system entry has no effect; the method does not throw an exception. システムエントリの値を調べるには、GetData メソッドを使用するか、GetDataに記載されている同等の AppDomainSetup プロパティを使用します。You can inspect the values of system entries with the GetData method, or the equivalent AppDomainSetup properties described in GetData.
このメソッドを呼び出して、正規表現パターンを評価するための既定のタイムアウト間隔の値を設定できます。そのためには、name
引数の値として "REGEX_DEFAULT_MATCH_TIMEOUT" を指定し、タイムアウト間隔を表す TimeSpan 値をdata
引数の値。You can call this method to set the value of the default timeout interval for evaluating regular expression patterns by supply "REGEX_DEFAULT_MATCH_TIMEOUT" as the value of the name
argument and a TimeSpan value that represents the timeout interval as the value of the data
argument. また、このメソッドを使用してユーザー定義の名前とデータのペアを挿入または変更し、GetData メソッドを使用してその値を検査することもできます。You can also insert or modify your own user defined name-data pairs with this method and inspect their values with the GetData method.
セキュリティ
SecurityCriticalAttribute
直前の呼び出し元に完全信頼が必要です。requires full trust for the immediate caller. このメンバーは、部分的に信頼されているコードまたは透過的なコードでは使用できません。This member cannot be used by partially trusted or transparent code.
こちらもご覧ください
SetData(String, Object, IPermission)
アプリケーション ドメインの特定のプロパティに対し、指定された値を代入します。プロパティの取得時に呼び出し元に要求するアクセス許可を引数として受け取ります。Assigns the specified value to the specified application domain property, with a specified permission to demand of the caller when the property is retrieved.
public:
void SetData(System::String ^ name, System::Object ^ data, System::Security::IPermission ^ permission);
[System.Security.SecurityCritical]
public void SetData (string name, object data, System.Security.IPermission permission);
member this.SetData : string * obj * System.Security.IPermission -> unit
Public Sub SetData (name As String, data As Object, permission As IPermission)
パラメーター
- name
- String
作成または変更の対象となるユーザー定義アプリケーション ドメイン プロパティの名前。The name of a user-defined application domain property to create or change.
- data
- Object
プロパティの値。The value of the property.
- permission
- IPermission
プロパティの取得時に呼び出し元に要求するアクセス許可。The permission to demand of the caller when the property is retrieved.
- 属性
例外
name
が null
です。name
is null
.
name
にシステム定義のプロパティ文字列が指定されているにもかかわらず、permission
が null
です。name
specifies a system-defined property string and permission
is not null
.
注釈
このメソッドを使用して、アプリケーションドメインのプロパティを記述する名前/データペアの内部キャッシュに、独自のユーザー定義エントリを挿入または変更します。Use this method to insert or modify your own user-defined entries in an internal cache of name/data pairs that describe properties of the application domain. エントリを挿入するときに、エントリを取得するときに適用するアクセス許可要求を指定できます。また、このメソッドを呼び出して、正規表現パターンを評価するための既定のタイムアウト間隔の値を設定できます。これには、name
引数の値として "REGEX_DEFAULT_MATCH_TIMEOUT" を指定し、タイムアウトを表す TimeSpan 値を指定します。data
引数の値としての間隔。When you insert an entry, you can specify a permission demand to enforce when the entry is retrieved.In addition, you can call this method to set the value of the default timeout interval for evaluating regular expression patterns by supply "REGEX_DEFAULT_MATCH_TIMEOUT" as the value of the name
argument and a TimeSpan value that represents the timeout interval as the value of the data
argument.
このメソッドを使用して、システム定義のプロパティ文字列にセキュリティ要求を割り当てることはできません。You cannot use this method to assign a security demand to a system-defined property string.
キャッシュには、アプリケーションドメインの作成時に挿入される定義済みのシステムエントリが自動的に含まれます。The cache automatically contains predefined system entries that are inserted when the application domain is created. このメソッドでシステムエントリを挿入または変更することはできません。You cannot insert or modify system entries with this method. システムエントリを変更しようとするメソッド呼び出しは効果がありません。メソッドは例外をスローしません。A method call that attempts to modify a system entry has no effect; the method does not throw an exception. システムエントリの値を調べるには、GetData メソッドを使用するか、GetData メソッドの「解説」で説明されている AppDomainSetup のプロパティを使用します。You can inspect the values of system entries with the GetData method or the equivalent AppDomainSetup properties described in the Remarks section for the GetData method.
セキュリティ
SecurityCriticalAttribute
直前の呼び出し元に完全信頼が必要です。requires full trust for the immediate caller. このメンバーは、部分的に信頼されているコードまたは透過的なコードでは使用できません。This member cannot be used by partially trusted or transparent code.