本文整理汇总了C#中System.AddIn.Hosting.AddInToken.Activate方法的典型用法代码示例。如果您正苦于以下问题:C# AddInToken.Activate方法的具体用法?C# AddInToken.Activate怎么用?C# AddInToken.Activate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.AddIn.Hosting.AddInToken
的用法示例。
在下文中一共展示了AddInToken.Activate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ChooseAddIn
// 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));
示例2: ChooseAddIn
//Ask the user which add-in they would like to use.
AddInToken selectedToken = ChooseAddIn(tokens);
//Activate the selected AddInToken in a new
//application domain with the Internet trust level.
Calculator CalcAddIn = selectedToken.Activate<Calculator>(AddInSecurityLevel.Internet);
//Run the add-in using a custom method.
RunCalculator(CalcAddIn);
示例3:
// Get the application domain
// of an existing add-in (CalcAddIn).
AddInController aiCtrl = AddInController.GetAddInController(CalcAddIn);
AppDomain AddInAppDom = aiCtrl.AppDomain;
// Activate another add-in in the same application domain.
Calculator CalcAddIn3 =
selectedToken2.Activate<Calculator>(AddInAppDom);
// Show that CalcAddIn3 was loaded
// into CalcAddIn's application domain.
AddInController aic = AddInController.GetAddInController(CalcAddIn3);
Console.WriteLine("Add-in loaded into existing application domain: {0}",
aic.AppDomain.Equals(AddInAppDom));
示例4: AddInProcess
// Create an external process.
AddInProcess pExternal = new AddInProcess();
// Activate an add-in in the external process
// with a full trust security level.
Calculator CalcAddIn4 =
selectedToken.Activate<Calculator>(pExternal,
AddInSecurityLevel.FullTrust);
// Show that the add-in is an external process
// by verifying that it is not in the current (host's) process.
AddInController AddinCtl = AddInController.GetAddInController(CalcAddIn4);
Console.WriteLine("Add-in in host's process: {0}",
AddinCtl.AddInEnvironment.Process.IsCurrentProcess);