C++ 中的简单 MEF 示例/ 命令行界面

发布于 2024-10-10 06:34:58 字数 502 浏览 0 评论 0原文

任何人都可以用 C++/CLI 给出简单的 MEF 示例吗?

最美好的祝愿

PS:我尝试转换 C# 示例,但遇到困难...例如,

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

在 C++/CLI 中,我无法访问 CompositionBatch 类重载方法 AddPart(object attributePart)CompositionBatch...编译器只看到AddPart(ComposablePart part)方法...事实上我下载了MEF的最新源代码(C#),在找不到任何方法使用 AddPart(object attributePart) 进行签名,但 Intellisense 将我显示为 C# 项目中的扩展,这让我更加困惑...

Anybody can give simple MEF example in C++/CLI?

Best Wishes

PS:I try to convert C# examples but have diffuculties...For example

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

In C++/CLI i can not reach CompositionBatch class overloaded method AddPart(object attributedPart) of CompositionBatch...Compiler just see AddPart(ComposablePart part) method...In fact i downloaded the latest source of MEF(in C#),in can not find any method signature with AddPart(object attributedPart) but Intellisense show me as an extension in a C# project which confuse me more...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦罢 2024-10-17 06:34:58

C++/CLI 不支持这种方式的扩展方法。扩展方法由编译器解析为绝对方法调用。该特定方法是 AttributedModelServices 类的扩展方法。这样称呼它:

AttributedModelServices::AddPart(batch, this);

C++/CLI doesn't support extension methods this way. Extension methods are resolved by the compiler into absolute method calls. That particular method is an extension method of the AttributedModelServices class. Call it as such:

AttributedModelServices::AddPart(batch, this);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文