AppDomainSetup.AppDomainInitializerArguments Özellik

Tanım

Temsilci tarafından AppDomainInitializer temsil edilen geri çağırma yöntemine geçirilen bağımsız değişkenleri alır veya ayarlar. Uygulama etki alanı başlatıldığında geri çağırma yöntemi çağrılır.

public:
 property cli::array <System::String ^> ^ AppDomainInitializerArguments { cli::array <System::String ^> ^ get(); void set(cli::array <System::String ^> ^ value); };
public string[] AppDomainInitializerArguments { get; set; }
member this.AppDomainInitializerArguments : string[] with get, set
Public Property AppDomainInitializerArguments As String()

Özellik Değeri

String[]

Geri çağırma yöntemi başlatma sırasında AppDomain çağrıldığında, temsilci tarafından AppDomainInitializer temsil edilen geri çağırma yöntemine geçirilen dize dizisi.

Örnekler

Aşağıdaki kod örneği, varsayılan uygulama etki alanından bir nesne ve kanıt kullanarak adlı ChildDomainbir AppDomainSetup alt uygulama etki alanı oluşturur. AppDomainInitializer özelliği, alt etki alanı başlatıldığında çağrılan geri çağırma yöntemine AppDomainInitayarlanır. Geri çağırma yönteminin bağımsız değişkenleri, özelliğine atanan bir dize dizisine AppDomainInitializerArguments yerleştirilir. Alt etki alanı oluşturulduğunda, geri çağırma yöntemi yalnızca dizeleri yazdırır.

using namespace System;
using namespace System::Security::Policy;

public ref class AppDomainInitializerExample
{
    // The callback method invoked when the child application domain is
    // initialized. The method simply displays the arguments that were
    // passed to it.
    //
public:
    static void AppDomainInit(array<String^>^ args)
    {
        Console::WriteLine("AppDomain \"{0}\" is initialized with these " +
            "arguments:", AppDomain::CurrentDomain->FriendlyName);
        for each (String^ arg in args)
        {
            Console::WriteLine("    {0}", arg);
        }
    }
};

int main()
{
    // Get a reference to the default application domain.
    //
    AppDomain^ currentDomain = AppDomain::CurrentDomain;
    
    // Create the AppDomainSetup that will be used to set up the child
    // AppDomain.
    AppDomainSetup^ domainSetup = gcnew AppDomainSetup();

    // Use the evidence from the default application domain to
    // create evidence for the child application domain.
    //
    Evidence^ evidence = gcnew Evidence(currentDomain->Evidence);

    // Create an AppDomainInitializer delegate that represents the
    // callback method, AppDomainInit. Assign this delegate to the
    // AppDomainInitializer property of the AppDomainSetup object.
    //
    AppDomainInitializer^ domainInitializer =
        gcnew AppDomainInitializer(AppDomainInitializerExample::AppDomainInit);
    domainSetup->AppDomainInitializer = domainInitializer;

    // Create an array of strings to pass as arguments to the callback
    // method. Assign the array to the AppDomainInitializerArguments
    // property.
    array<String^>^ initialArguments = {"String1", "String2"};
    domainSetup->AppDomainInitializerArguments = initialArguments;

    // Create a child application domain named "ChildDomain", using
    // the evidence and the AppDomainSetup object.
    //
    AppDomain^ appDomain = AppDomain::CreateDomain("ChildDomain",
        evidence, domainSetup);

    Console::WriteLine("Press the Enter key to exit the example program.");
    Console::ReadLine();
}

/* This code example produces the following output:

AppDomain "ChildDomain" is initialized with these arguments:
String1
String2
*/
using System;
using System.Security.Policy;

public class Example
{
    public static void Main()
    {
        // Get a reference to the default application domain.
        //
        AppDomain current = AppDomain.CurrentDomain;

        // Create the AppDomainSetup that will be used to set up the child
        // AppDomain.
        AppDomainSetup ads = new AppDomainSetup();

        // Use the evidence from the default application domain to
        // create evidence for the child application domain.
        //
        Evidence ev = new Evidence(current.Evidence);

        // Create an AppDomainInitializer delegate that represents the
        // callback method, AppDomainInit. Assign this delegate to the
        // AppDomainInitializer property of the AppDomainSetup object.
        //
        AppDomainInitializer adi = new AppDomainInitializer(AppDomainInit);
        ads.AppDomainInitializer = adi;

        // Create an array of strings to pass as arguments to the callback
        // method. Assign the array to the AppDomainInitializerArguments
        // property.
        string[] initArgs = {"String1", "String2"};
        ads.AppDomainInitializerArguments = initArgs;

        // Create a child application domain named "ChildDomain", using
        // the evidence and the AppDomainSetup object.
        //
        AppDomain ad = AppDomain.CreateDomain("ChildDomain", ev, ads);

        Console.WriteLine("Press the Enter key to exit the example program.");
        Console.ReadLine();
    }

    // The callback method invoked when the child application domain is
    // initialized. The method simply displays the arguments that were
    // passed to it.
    //
    public static void AppDomainInit(string[] args)
    {
        Console.WriteLine("AppDomain \"{0}\" is initialized with these arguments:",
            AppDomain.CurrentDomain.FriendlyName);
        foreach (string arg in args)
        {
            Console.WriteLine("    {0}", arg);
        }
    }
}

/* This code example produces the following output:

AppDomain "ChildDomain" is initialized with these arguments:
    String1
    String2
 */
open System
open System.Security.Policy

// Get a reference to the default application domain.
let current = AppDomain.CurrentDomain

// Create the AppDomainSetup that will be used to set up the child
// AppDomain.
let ads = AppDomainSetup()

// Use the evidence from the default application domain to
// create evidence for the child application domain.
let ev = Evidence current.Evidence

// The callback function invoked when the child application domain is
// initialized. The function simply displays the arguments that were
// passed to it.
let appDomainInit args =
    printfn $"AppDomain \"{AppDomain.CurrentDomain.FriendlyName}\" is initialized with these arguments:"
    for arg in args do
        printfn $"    {arg}"

// Create an AppDomainInitializer delegate that represents the
// callback method, AppDomainInit. Assign this delegate to the
// AppDomainInitializer property of the AppDomainSetup object.
let adi = AppDomainInitializer appDomainInit
ads.AppDomainInitializer <- adi

// Create an array of strings to pass as arguments to the callback
// method. Assign the array to the AppDomainInitializerArguments
// property.
let initArgs = [| "String1"; "String2" |]
ads.AppDomainInitializerArguments <- initArgs

// Create a child application domain named "ChildDomain", using
// the evidence and the AppDomainSetup object.
let ad = AppDomain.CreateDomain("ChildDomain", ev, ads)

printfn "Press the Enter key to exit the example program."
stdin.ReadLine() |> ignore

(* This code example produces the following output:

AppDomain "ChildDomain" is initialized with these arguments:
    String1
    String2
 *)
Imports System.Security.Policy

Public Class Example

    Public Shared Sub Main()

        ' Get a reference to the default application domain.
        '
        Dim current As AppDomain = AppDomain.CurrentDomain

        ' Create the AppDomainSetup that will be used to set up the child
        ' AppDomain.
        Dim ads As New AppDomainSetup()

        ' Use the evidence from the default application domain to
        ' create evidence for the child application domain.
        '
        Dim ev As Evidence = New Evidence(current.Evidence)

        ' Create an AppDomainInitializer delegate that represents the 
        ' callback method, AppDomainInit. Assign this delegate to the
        ' AppDomainInitializer property of the AppDomainSetup object.
        '
        Dim adi As New AppDomainInitializer(AddressOf AppDomainInit)
        ads.AppDomainInitializer = adi

        ' Create an array of strings to pass as arguments to the callback
        ' method. Assign the array to the AppDomainInitializerArguments
        ' property.
        Dim initArgs() As String = {"String1", "String2"}
        ads.AppDomainInitializerArguments = initArgs

        ' Create a child application domain named "ChildDomain", using 
        ' the evidence and the AppDomainSetup object.
        '
        Dim ad As AppDomain = _
            AppDomain.CreateDomain("ChildDomain", ev, ads)

        Console.WriteLine("Press the Enter key to exit the example program.")
        Console.ReadLine()
    End Sub

    ' The callback method invoked when the child application domain is
    ' initialized. The method simply displays the arguments that were
    ' passed to it.
    '
    Public Shared Sub AppDomainInit(ByVal args() As String)
        Console.WriteLine("AppDomain ""{0}"" is initialized with these arguments:", _
            AppDomain.CurrentDomain.FriendlyName)
        For Each arg As String In args
            Console.WriteLine("    {0}", arg)
        Next
    End Sub
End Class

' This code example produces the following output:
'
'AppDomain "ChildDomain" is initialized with these arguments:
'    String1
'    String2

Açıklamalar

AppDomainInitializer Başlatma sırasında AppDomain çağrılan bir geri çağırma yöntemi belirtmek için özelliğini kullanın. AppDomainInitializer Özellik ayarlanmadıysa, bu özelliğe atanan dizi kullanılmaz.

Geri çağırma yöntemi, yeni oluşturulan uygulama etki alanı bağlamında yürütülür.

Şunlara uygulanır

Ayrıca bkz.