如何在VS.NET扩展包中注册IVsEditorFactoryNotify?

时间:2013-08-01 21:02:01

标签: visual-studio

我正在尝试监控项目添加的事件。

我创建了一个自定义编辑器工厂,例如

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事件之外的其他方式?

谢谢

1 个答案:

答案 0 :(得分:0)

您不需要这里的编辑器工厂,那就是您想要提供自定义编辑器(如Visual Studio中的文本编辑器)。您应该考虑与项目系统集成。我不记得通过较新的项目系统做到这一点的方法,但你可能会逃脱http://msdn.microsoft.com/en-US/library/microsoft.visualstudio.shell.interop.ivshierarchyevents(v=vs.110).aspx