當前位置: 首頁>>代碼示例>>C#>>正文


C# AddInToken.Activate方法代碼示例

本文整理匯總了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));
開發者ID:.NET開發者,項目名稱:System.AddIn.Hosting,代碼行數:18,代碼來源:AddInToken.Activate

示例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);
開發者ID:.NET開發者,項目名稱:System.AddIn.Hosting,代碼行數:9,代碼來源:AddInToken.Activate

示例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));
開發者ID:.NET開發者,項目名稱:System.AddIn.Hosting,代碼行數:14,代碼來源:AddInToken.Activate

示例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);
開發者ID:.NET開發者,項目名稱:System.AddIn.Hosting,代碼行數:14,代碼來源:AddInToken.Activate


注:本文中的System.AddIn.Hosting.AddInToken.Activate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。