有人知道如何为C ++ Project Property规则实现DynamicEnumProperty类型 [英] Does anyone know how to implement the DynamicEnumProperty type for C++ Project Property rules
问题描述
我正在为C ++项目的自定义构建配置添加一个属性。我想要属性组合框显示可以在代码中设置的值的动态列表。我认为这应该使用DynamicEnumProperty类型,但我不确定它的实现。有没有人在这个房子上工作,可以指出我正确的方向?
I am trying to add a property to our custom build configuration for a C++ project. I want the property combo box to display a dynamic list of values that I can set in code. I think that this should be done using the DynamicEnumProperty type but I am unsure of its implementation. Has anyone worked with this property before that can point me in the right direction?
谢谢
推荐答案
我知道这是一个古老的问题,但您仍然可以享受解决方案;)
I know it's a bit old question... but you might still enjoy the solution ;)
除了引用程序集和导出所需类型MEF作为Dmitry上面解释的,您还需要将VSPackage标记为启用MEF,以便通过合同进行扫描。通过编辑source.extension.vsixmanifest:
Beside referencing the assemblies and exporting desired type via MEF as Dmitry explained above, you also need to mark the VSPackage as MEF-enabled to make it scan though your contracts. Do it by editing source.extension.vsixmanifest:
for VS2010:
for VS2010:
<Content>
<VsPackage>|%CurrentProject%;PkgdefProjectOutputGroup|</VsPackage>
<MefComponent>|%CurrentProject%|</MefComponent>
</Content>
<Assets>
<Asset Type="Microsoft.VisualStudio.MefComponent" d:Source="Project"
d:ProjectName="%CurrentProject%" Path="|%CurrentProject%|" />
</Assets>
这应该让你在导出的类中设置一个断点。
This should let you hit a breakpoint set in an exported class.
此外,如果您需要在运行时手动创建对象,则可以使用VisualStudio的内部组合容器。从任何地方访问它的最简单的方法是:
Additionally, if you need to create an object at runtime 'manually', you can use VisualStudio's internal composition container. The simplest way to access it from anywhere is:
var container = Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SComponentModel)) as IComponentModel;
var service = container.GetService<SVsXYZ>();
我稍后会在这里添加一个示例: https://github.com/phofman/vs-plugin ,所以只需把链接以备将来参考。
I will shortly add a sample here: https://github.com/phofman/vs-plugin, so just putting the link for future reference.
这篇关于有人知道如何为C ++ Project Property规则实现DynamicEnumProperty类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!