Visual Studio SDK-处理文件保存事件 [英] Visual Studio SDK - Handle File Save Event

查看:110
本文介绍了Visual Studio SDK-处理文件保存事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Visual Studio中保存具有某些扩展名的文件后,我想运行一个脚本.我想知道用于保存文件的事件处理程序在Visual Studio SDK API中的什么位置.

在Visual Studio扩展的API文档方面,任何人都可以向我指出正确的方向.我已经找到了 Visual Studio SDK参考,但是一些指导或示例示例会有所帮助.

我想创建通常在构建项目时(Mono for Android Project)生成的部分设计器文件,我的文件将具有临时值,但仅用于在不构建整个项目的情况下启用智能感知.我现在可以手动运行该过程,但是我想在保存.xml或.axml文件时触发脚本.

它认为我需要使用 IVsRunningDocTableEvents.OnAfterSave 方法,但是我不确定如何获取正在运行的doc表上的句柄,或者如何过滤要为其运行事件的文件.这是我第一次尝试使用Visual Studio SDK.

解决方案

用于保存文件的事件处理程序为:

Dte.Events.DocumentEvents.DocumentSaved

请注意,您需要保留对EventsDocumentEvents的引用才能使其真正起作用.这是有关此的一些信息: http://social.msdn.microsoft.com/Forums/br/vsx/thread/0857a868-e650-42ed-b9cc-2975dc46e994

这里是30个示例项目的链接,这些示例项目说明了Visual Studio加载项的各种功能:

http://code.msdn.microsoft.com/Visual- Studio-2010-SDK-ddfe1372

您可以在此处找到一些入门信息:

http://msdn.microsoft.com/en-us/vstudio/ff677564.aspx

I would like to run a script after files with certain extensions are saved in visual studio. I am wondering where the event handler for saving a file is located in the Visual Studio SDK API.

Can anyone point me in the right direction in terms of API documentation for visual studio extensions. I have found the Visual Studio SDK Reference but some direction or sample examples would be helpful.

I want to create partial designer files that are usually generated when the project is built (Mono for Android Project), my files will have temporary values, but are only intended to enable intellisense without building the entire project. I can run the process manually right now, but I would like to trigger the script when .xml or .axml files are saved.

It think I need to work with IVsRunningDocTableEvents.OnAfterSave method, but I'm not sure about how I get the handle on the running doc table, or how I filter the files I want to run the event for. This is my first attempt at using the Visual Studio SDK.

解决方案

The event handler for saving files is:

Dte.Events.DocumentEvents.DocumentSaved

Note you need to keep a reference to Events and DocumentEvents in order for it to actually work. Here is some information on that: http://social.msdn.microsoft.com/Forums/br/vsx/thread/0857a868-e650-42ed-b9cc-2975dc46e994

Here is a link to 30 sample projects that illustrate all kinds of functionality for Visual Studio Add-Ins:

http://code.msdn.microsoft.com/Visual-Studio-2010-SDK-ddfe1372

You can find some getting started informatin here:

http://msdn.microsoft.com/en-us/vstudio/ff677564.aspx

这篇关于Visual Studio SDK-处理文件保存事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆