public static FindFilesXML CreateNew(Solution solution) { var projects = solution.Projects; var findFiles = new FindFilesXML() { projects = new Project[projects.Count] }; int i = 0; foreach (EnvDTE.Project proj in projects) { findFiles.projects[i] = new Project { name = proj.Name, enabled = false, folders = new string[] { "./" }, matches = new string[] { "*.cs" } }; i++; } Save(solution, findFiles); return(findFiles); }
public static void Save(Solution solution, FindFilesXML findFiles) { string path = getPath(solution); using (var steam = new StreamWriter(path)) { var x = new XmlSerializer(typeof(FindFilesXML)); x.Serialize(steam, findFiles); } }
private void refreshFileList() { if (this.dte2 == null) { this.dte2 = (DTE2)this.ServiceProvider.GetService(typeof(DTE)); } var solution = this.dte2.Solution; FindFilesXML findFiles; if (!FindFilesXML.Load(solution, out findFiles)) { findFiles = FindFilesXML.CreateNew(solution); MessageBox.Show("Created new FindFilesXML\nPlease edit it and run again"); return; } var projects = this.dte2.Solution.Projects; var basePath = FindFilesXML.GetBasePath(solution); new System.Threading.Tasks.Task(() => { MessageBox.Show("Starting Auto find files"); }).Start(); foreach (Project proj in projects) { if (!findFiles.ProjectExists(proj.Name)) { MessageBox.Show(string.Format("Project with name '{0}' does not exist", proj.Name)); continue; } var data = findFiles[proj.Name]; if (data.enabled) { this.refreshProject(data, proj, basePath); } } MessageBox.Show("Finished Auto find files"); }
public static bool Load(Solution solution, out FindFilesXML findFiles) { string path = getPath(solution); findFiles = null; if (!File.Exists(path)) { return(false); } using (var steam = new StreamReader(path)) { try { var x = new XmlSerializer(typeof(FindFilesXML)); findFiles = x.Deserialize(steam) as FindFilesXML; } catch (Exception e) { MessageBox.Show("Could Not Deserialize FindFilesXML\n" + e.Message); return(false); } } return(findFiles != null); }