Partager via


AddInController.AddInEnvironment Propriété

Définition

Obtient un objet AddInEnvironment.

public:
 property System::AddIn::Hosting::AddInEnvironment ^ AddInEnvironment { System::AddIn::Hosting::AddInEnvironment ^ get(); };
public System.AddIn.Hosting.AddInEnvironment AddInEnvironment { get; }
member this.AddInEnvironment : System.AddIn.Hosting.AddInEnvironment
Public ReadOnly Property AddInEnvironment As AddInEnvironment

Valeur de propriété

Objet qui peut être utilisé pour activer d'autres compléments dans le même environnement que le complément d'origine.

Exemples

L’exemple suivant active un deuxième complément dans le même environnement que le premier complément.

// Get the AddInController of a
// currently actived add-in (CalcAddIn).
AddInController aiController = AddInController.GetAddInController(CalcAddIn);

// Select another token.
AddInToken selectedToken2 = ChooseAddIn(tokens);

// Activate a second add-in, CalcAddIn2, in the same
// appliation domain and process as the first add-in by passing
// the first add-in's AddInEnvironment object to the Activate method.
AddInEnvironment aiEnvironment = aiController.AddInEnvironment;
Calculator CalcAddIn2 =
    selectedToken2.Activate<Calculator>(aiEnvironment);

// Get the AddInController for the second add-in to compare environments.
AddInController aiController2 = AddInController.GetAddInController(CalcAddIn2);
Console.WriteLine("Add-ins in same application domain: {0}", aiController.AppDomain.Equals(aiController2.AppDomain));
Console.WriteLine("Add-ins in same process: {0}", aiEnvironment.Process.Equals(aiController2.AddInEnvironment.Process));
' Get the AddInController of a 
' currently activated add-in (CalcAddIn).
Dim aiController As AddInController = AddInController.GetAddInController(CalcAddIn)

' Select another token.
Dim selectedToken2 As AddInToken = ChooseAddIn(tokens)

' Activate a second add-in, CalcAddIn2, in the same
' appliation domain and process as the first add-in by passing
' the first add-in's AddInEnvironment object to the Activate method.

Dim aiEnvironment As AddInEnvironment = aiController.AddInEnvironment
Dim CalcAddIn2 As Calculator = _
    selectedToken2.Activate(Of Calculator)(aiEnvironment)

' Get the AddInController for the second add-in to compare environments.
Dim aiController2 As AddInController = AddInController.GetAddInController(CalcAddIn2)

Console.WriteLine("Add-ins in same application domain: {0}", _
    aiController.AppDomain.Equals(aiController2.AppDomain))
Console.WriteLine("Add-ins in same process: {0}", _
    aiEnvironment.Process.Equals(aiController2.AddInEnvironment.Process))

Remarques

Utilisez cette propriété pour obtenir l’objet AddInEnvironment d’un complément. Utilisez ensuite cet objet pour activer d’autres compléments dans le même domaine d’application et le même processus que le complément d’origine.

S’applique à