/// <summary> /// Formats a document. /// </summary> /// <param name="doc">The document to format.</param> public void FormatDocument(Document doc) { // If the user disabled the plugin, bail. if (!Options.Storage.ReadBoolean(Options.GetPageName(), Options.FormatOnSave)) { return; } // If the document isn't text or an enabled language, bail. TextDocument textDoc = doc as TextDocument; if (textDoc == null || !this.LanguageSelectedForFormatting(textDoc.Language)) { return; } // You can only format the active document, so we have to temporarily // activate each document that needs formatting. Document active = CodeRush.Documents.Active; if (textDoc != active) { textDoc.Activate(); } CodeRush.Documents.Format(); if (textDoc != active) { active.Activate(); } }
private void events_ProjectBuildDone(string project, string projectConfiguration, string platform, string solutionConfiguration, bool succeeded) { if (succeeded) { string gacUtilPath = Options.Storage.ReadString(Options.GetPageName(), Options.GacUtilPath); if (File.Exists(gacUtilPath)) { Project dteProject = CodeRush.Solution.Active.FindProjectFromUniqueName(project); if (ProjectExists(dteProject)) { Environment.CurrentDirectory = Path.GetDirectoryName(gacUtilPath) + ""; string outputPath = dteProject.FindOutputPath(); if (File.Exists(outputPath)) { Process.Start("gacutil.exe", "/i " + @"""" + outputPath + @""" /f"); } } else { Log.Send("GagUtl Project Not Found:", dteProject.FileName); } } } }