gpt4 book ai didi

c++ - C++/CLI 中的简单 MEF 示例

转载 作者:太空宇宙 更新时间:2023-11-04 12:21:45 24 4
gpt4 key购买 nike

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

祝福

PS:我尝试转换C#例子但是有困难...例如

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

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

最佳答案

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

AttributedModelServices::AddPart(batch, this);

关于c++ - C++/CLI 中的简单 MEF 示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4601896/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com