我正在尝试监视项目添加事件。
我创建了一个自定义编辑器工厂,如
public class ProjectEditorFactory : IVsEditorFactoryNotify, IVsEditorFactory
{
public int NotifyDependentItemSaved(IVsHierarchy pHier, uint itemidParent, string pszMkDocumentParent, uint itemidDpendent, string pszMkDocumentDependent)
{
return VSConstants.S_OK;
}
public int NotifyItemAdded(uint grfEFN, IVsHierarchy pHier, uint itemid, string pszMkDocument)
{
return VSConstants.S_OK;
}
public int NotifyItemRenamed(IVsHierarchy pHier, uint itemid, string pszMkDocumentOld, string pszMkDocumentNew)
{
return VSConstants.S_OK;
}
............
}
然后在我的包的初始化方法
我做
RegisterEditorFactory( new ProjectEditorFactory());
但在我运行之后,在我向项目添加新项之后,事件处理程序不会被命中。
有人知道如何赶上这个活动吗?
我真正想要的是在语法上添加一些文件,然后创建一个特定文件的依赖项。除了听ItemAdded事件,还有人知道其他方法吗?
感谢
这里不需要编辑器工厂,而需要提供自定义编辑器(如Visual Studio中的文本编辑器)。您应该考虑与项目系统集成。我不记得通过更新的项目系统做这件事的方法,但你可能可以逃脱惩罚http://msdn.microsoft.com/en-US/library/microsoft.visualstudio.shell.interop.ivshierarchyevents(v=vs.110).aspx