private SourceView(Board <TItem, TDescription, TNode> board, FileLine path, String text) { Lines = new Dictionary <int, SourceLine>(); IEnumerable <TItem> boardItems = board.Where(boardItem => { return(boardItem.Description != null && boardItem.Description.Path != null && boardItem.Description.Path.File == path.File); }); foreach (TItem item in boardItems) { foreach (TNode node in item.Nodes) { SourceLine line = null; if (!Lines.TryGetValue(node.Description.Path.Line, out line)) { line = new SourceLine(); Lines.Add(node.Description.Path.Line, line); } line.Add(node); } } SourceFile = path; Text = text; }
public static SourceView <TItem, TDescription, TNode> Create(Board <TItem, TDescription, TNode> board, FileLine path) { if (path == null || String.IsNullOrEmpty(path.File)) { return(null); } String file = path.File; while (!File.Exists(file)) { OpenFileDialog openFileDialog = new OpenFileDialog(); String filter = path.ShortName; openFileDialog.Title = String.Format("Where can I find {0}?", filter); openFileDialog.ShowReadOnly = true; openFileDialog.FileName = filter; if (openFileDialog.ShowDialog() == true) { file = openFileDialog.FileName; } else { return(null); } } return(new SourceView <TItem, TDescription, TNode>(board, path, File.ReadAllText(file))); }