从 Visual Studio MEF 编辑器扩展访问项目系统
我正在使用 VS 2010 SDK RC 编写 Visual Studio 编辑器扩展。我希望能够弄清楚当前项目的参考文献是什么。如何访问当前编辑器对应的项目?
有关编辑器扩展的文档没有似乎包含有关如何访问 Visual Studio 的非编辑器部分的信息。我做了一些搜索,看起来在 VS2008 中您可以编写可以访问项目系统的加载项,但我正在尝试从 MEF 编辑器扩展中获取此功能。
I'm writing a Visual Studio editor extension using the VS 2010 SDK RC. I'd like to be able to figure out what the references of the current project are. How do I get access to the project corresponding to the current editor?
The documentation on editor extensions doesn't seem to include information on how to access non-editor parts of Visual Studio. I did some searching and it looks like in VS2008 you could write add-ins that would access the project system, but I'm trying to get at this functionality from a MEF editor extension.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Daniel——
从编辑到项目是一个多步骤的过程。首先,您在编辑器中获取文件的文件名,然后从那里您可以找到包含的项目。
假设你有一个 IWPFTextView,你可以像这样获取文件名:
一旦你有了文件名,你就可以像这样获取它的父项目:
从项目中你可以获取代码模型,我假设引用,但是我还不需要这样做。
希望这会有所帮助......
〜卡梅伦
Daniel --
Getting from the editor to the project is a multiple step process. First, you get the filename of the file in the editor, and from there you can find the containing project.
Assuming you've got an IWPFTextView, you can get the filename like this:
Once you've got a filename, you can get it's parent project like this:
From the project you can get to the codemodel, and I assume the references, but I haven't needed to do that yet.
Hope this helps...
~ Cameron