MAF(System.AddIn)中的AddIns可以有構造函數參數嗎?

[英]Can AddIns in MAF (System.AddIn) have constructor parameters?


I need to pass configuration settings to an AddIn created using the Managed AddIn Framework (MAF, aka System.AddIn). Can a put a settings parameter in the AddIn's constructor?

我需要將配置設置傳遞給使用Managed AddIn Framework(MAF,又名System.AddIn)創建的AddIn。可以在AddIn的構造函數中放置一個設置參數嗎?

Another option would be to create an Initialize() method, but then I have to remember to call it before doing any work with the AddIn.

另一個選擇是創建一個Initialize()方法,但是我必須記住在使用AddIn進行任何工作之前調用它。

2 个解决方案

#1


Best way is to use Initalize() method, because the pipelines use the constructor parameters for passing contracts.

最好的方法是使用Initalize()方法,因為管道使用構造函數參數來傳遞合同。

#2


I too use an Initialize() method in my add-ins. Indeed System.AddIn invokes the parameterless constructor of the add-in class.

我也在我的加載項中使用Initialize()方法。實際上,System.AddIn調用外接程序類的無參數構造函數。

Here is an explanation of what goes on during the activation of an add-in. It is an old post but the activation process is still the same. You can also check the source code of the System.AddIn assembly from Microsoft's Shared Source Initiative. You can download the one with Product Name = .Net and Version = 4 for Framework 4, install it and then look for AddInToken.cs (it will lead you to AddInActivator.cs).

以下是對加載項激活期間發生的事情的解釋。這是一個老帖子,但激活過程仍然是相同的。您還可以從Microsoft的Shared Source Initiative檢查System.AddIn程序集的源代碼。您可以為Framework 4下載Product Name = .Net和Version = 4的那個,安裝它然后查找AddInToken.cs(它將引導您進入AddInActivator.cs)。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2009/05/07/720db8633352a2e2da1eafbc7af154a2.html



 
粤ICP备14056181号  © 2014-2021 ITdaan.com