2011-01-05 63 views
1

任何人都可以在C++/CLI中給出簡單的MEF示例?C++/CLI中的簡單MEF示例

最良好的祝願

PS:我嘗試轉換C#的​​例子,但有diffuculties ...例如

CompositionBatch^ batch = gcnew CompositionBatch(); 
batch->AddPart(this); 

在C++/CLI我不能達到CompositionBatch類重載方法的CompositionBatchAddPart(object attributedPart) .. 。編譯器只看到AddPart(ComposablePart part)方法...實際上,我下載了MEF的最新來源(在C#中),在AddPart(object attributedPart)找不到任何方法簽名,但Intellisense顯示我作爲C#項目中的一個擴展,使我更加困惑...

回答

1

C++/CLI不支持這種擴展方法。編譯器將擴​​展方法解析爲絕對方法調用。該特定方法是AttributedModelServices類的擴展方法。這樣稱呼:

AttributedModelServices::AddPart(batch, this); 
+0

謝謝..這個作品... – NoviceAndNovice 2011-01-05 13:34:23