public void Edit(Project project) { string str = Path.Combine(ProjectExtensions.GetFullPath(project), "web.config"); if (project.DTE.SourceControl.IsItemUnderSCC(str) && !project.DTE.SourceControl.IsItemCheckedOut(str) && !project.DTE.SourceControl.CheckOutItem(str)) { return; } IEditorInterfaces orOpenDocument = this.VisualStudio.Editor.GetOrOpenDocument(str); Marshal.ThrowExceptionForHR(orOpenDocument.VsTextBuffer.Reload(1)); ITextBuffer textBuffer = orOpenDocument.TextBuffer; using (ITextEdit textEdit = textBuffer.CreateEdit()) { string editedText = this.GetEditedText(textEdit.Snapshot.GetText()); if (editedText != null) { textEdit.Replace(new Span(0, textBuffer.CurrentSnapshot.Length), editedText); textEdit.Apply(); this.VisualStudio.Editor.FormatDocument(str); Document document = project.DTE.Documents.Item(str); document.Save(""); } } }
public void UpdateConfiguration(CodeGenerationContext context) { if (context == null) { throw new ArgumentNullException("context"); } Project project = context.ActiveProject; string webConfigPath = Path.Combine(project.GetFullPath(), CommonFilenames.WebConfig); IEditorInterfaces editor = VisualStudioIntegration.Editor.GetOrOpenDocument(webConfigPath); }