int IVsRunningDocTableEvents.OnAfterSave(uint docCookie) { uint flags, readLocks, editLocks, itemId; string moniker; IVsHierarchy hierarchy; IntPtr docData; int hr = rdt.GetDocumentInfo( docCookie, out flags, out readLocks, out editLocks, out moniker, out hierarchy, out itemId, out docData); if (hr == VSConstants.S_OK) { var e = new AfterSaveEventArgs { FileName = moniker}; this.OnAfterSave(e); } return VSConstants.S_OK; }
protected abstract void OnAfterSave(AfterSaveEventArgs e);
protected override void OnAfterSave(AfterSaveEventArgs e) { if (Path.GetExtension(e.FileName) == ".csproj") { var root = XElement.Load(e.FileName); var nspace = root.Name.Namespace; var element = root.Elements(nspace + "PropertyGroup") .Elements(nspace + "AutoConvertHintPath") .FirstOrDefault(); bool flg; bool.TryParse(element?.Value, out flg); if (flg) { UpdateCsProj(e.FileName); } } }