internal SolutionFileBase GetOrCreateFileReference(string path) { path = path.TrimStart('/', '\\'); if (Path.IsPathRooted(path)) { path = path.Substring(this.curWorkspace.WorkingDir.Length + 1); } ICollection <SolutionFileBase> sfbCollection = null; SolutionFileBase sfbCollectionOwner = null; var parent = Path.GetDirectoryName(path); var filename = Path.GetFileName(path); if (string.IsNullOrWhiteSpace(parent)) { sfbCollection = this.FilesCollection; } else { SolutionFileBase.WalkThrough(this.FilesCollection, (it) => { if (it.RelativePath.Equals(parent, StringComparison.CurrentCultureIgnoreCase)) { sfbCollectionOwner = it; sfbCollection = it.Children; return(true); } return(false); }); } if (sfbCollection == null) { sfbCollectionOwner = GetOrCreateFileReference(parent); sfbCollection = sfbCollectionOwner.Children; } foreach (var it in sfbCollection) { if (it.FileName.Equals(filename, StringComparison.CurrentCultureIgnoreCase)) { return(it); } } SolutionFileBase sfb; if ((File.GetAttributes(Path.Combine(this.curWorkspace.WorkingDir, path)) & FileAttributes.Directory) > 0) { sfb = new SolutionFolder() { FileName = filename, Parent = sfbCollectionOwner }; } else { sfb = new SolutionFile() { FileName = filename, Parent = sfbCollectionOwner }; } sfbCollection.Add(sfb); return(sfb); }
internal void RestoreFromXml() { SolutionFileBase.WalkThrough(this.FilesCollection, (it) => { if (it.Children != null) { foreach (var child in it.Children) { if (child.Parent != it) { child.Parent = it; } } } return(false); }); }
private void FSWatcher_Changed(object sender, FileSystemEventArgs e) { SolutionFile solutionFile = null; var existsInSolution = SolutionFileBase.WalkThrough(this.FilesCollection, (sfb) => { if (sfb is SolutionFile && sfb.FullPath.Equals(sfb.FullPath, StringComparison.CurrentCultureIgnoreCase)) { solutionFile = sfb as SolutionFile; return(true); } return(false); }); if (existsInSolution) { DocumentBase docBase = null; foreach (var it in this.curWorkspace.DocumentsDisplayed) { if (it.FilePath == e.FullPath) { docBase = it; break; } } if (docBase == null) { return; } var msgBoxResult = MessageBox.Show(Properties.Localization.MessageBoxFileChanged_Body, Properties.Localization.MessageBoxFileChanged_Title, MessageBoxButton.YesNo, MessageBoxImage.Information); if (msgBoxResult != MessageBoxResult.Yes) { return; } docBase.ReloadDocument(); } }