private void InvokeRemovedFile(TreeFile file) { file.MarkAsDeleted(); var handler = file.StagedStatus == StagedStatus.Staged ? RemovedStagedFile : RemovedUnstagedFile; handler?.Invoke(this, new TreeFileEventArgs(file)); }
private void OnFileDeleted(TreeFile file) { var handler = FileDeleted; if (handler != null) { handler(this, new TreeFileEventArgs(file)); } }
public static void UpdateTreeFile(TreeFile treeFile, TreeFileData treeFileData) { Verify.Argument.IsNotNull(treeFile, "treeFile"); Verify.Argument.IsNotNull(treeFileData, "treeFileData"); treeFile.ConflictType = treeFileData.ConflictType; treeFile.Status = treeFileData.FileStatus; treeFile.StagedStatus = treeFileData.StagedStatus; }
private void InvokeFileAdded(TreeFile file) { var handler = FileAdded; if (handler != null) { handler(this, new TreeFileEventArgs(file)); } }
private void InvokeNewFile(TreeFile file) { var handler = file.StagedStatus == StagedStatus.Staged ? NewStagedFile : NewUnstagedFile; if (handler != null) { handler(this, new TreeFileEventArgs(file)); } }
private static void Remove(TreeFile file) { var from = file.Parent; from.Files.Remove(file); if (from.Files.Count == 0 && from.Directories.Count == 0 && from.Parent != null) { Remove(from); } }
private void SetContent(IList <TreeContentData> tree) { Root.Files.Clear(); Root.Directories.Clear(); var trees = new Dictionary <string, TreeDirectory>(); foreach (var item in tree) { int slashPos = item.Name.IndexOf('/'); string name = (slashPos == -1)?(item.Name):GetName(item.Name); var parent = _root; while (slashPos != -1) { string parentPath = item.Name.Substring(0, slashPos); TreeDirectory p; if (!trees.TryGetValue(parentPath, out p)) { p = new TreeDirectory(Repository, parentPath, parent, GetName(parentPath)); parent.AddDirectory(p); trees.Add(parentPath, p); } parent = p; slashPos = item.Name.IndexOf('/', slashPos + 1); } switch (item.Type) { case TreeContentType.Tree: { var dir = new TreeDirectory(Repository, item.Name, parent, name); trees.Add(item.Name, dir); parent.AddDirectory(dir); } break; case TreeContentType.Blob: { var blob = new TreeFile(Repository, item.Name, parent, FileStatus.Cached, name, ((BlobData)item).Size); parent.AddFile(blob); } break; case TreeContentType.Commit: { var commit = new TreeCommit(Repository, item.Name, parent, FileStatus.Cached, name); parent.AddCommit(commit); } break; } } }
public TreeFileEventArgs(TreeFile file) { File = file; }
private void OnFileDeleted(TreeFile file) { var handler = FileDeleted; if(handler != null) handler(this, new TreeFileEventArgs(file)); }
private void InvokeFileAdded(TreeFile file) { var handler = FileAdded; if(handler != null) handler(this, new TreeFileEventArgs(file)); }
internal void RemoveFile(TreeFile file) { file.Parent = null; _files.Remove(file); OnFileDeleted(file); }
private void InvokeRemovedFile(TreeFile file) { file.MarkAsDeleted(); var handler = file.StagedStatus == StagedStatus.Staged ? RemovedStagedFile : RemovedUnstagedFile; if(handler != null) handler(this, new TreeFileEventArgs(file)); }
internal void AddFile(TreeFile file) { file.Parent = this; _files.Add(file); InvokeFileAdded(file); }
private void OnFileDeleted(TreeFile file) { FileDeleted?.Invoke(this, new TreeFileEventArgs(file)); }
private void InvokeFileAdded(TreeFile file) { FileAdded?.Invoke(this, new TreeFileEventArgs(file)); }
private static void Remove(TreeFile file) { var from = file.Parent; from.Files.Remove(file); if(from.Files.Count == 0 && from.Directories.Count == 0 && from.Parent != null) { Remove(from); } }
private void InvokeNewFile(TreeFile file) { var handler = file.StagedStatus == StagedStatus.Staged ? NewStagedFile : NewUnstagedFile; if(handler != null) handler(this, new TreeFileEventArgs(file)); }
private void SetContent(IList<TreeContentData> tree) { Root.Files.Clear(); Root.Directories.Clear(); var trees = new Dictionary<string, TreeDirectory>(); foreach(var item in tree) { int slashPos = item.Name.IndexOf('/'); string name = (slashPos == -1)?(item.Name):GetName(item.Name); var parent = _root; while(slashPos != -1) { string parentPath = item.Name.Substring(0, slashPos); TreeDirectory p; if(!trees.TryGetValue(parentPath, out p)) { p = new TreeDirectory(Repository, parentPath, parent, GetName(parentPath)); parent.AddDirectory(p); trees.Add(parentPath, p); } parent = p; slashPos = item.Name.IndexOf('/', slashPos + 1); } switch(item.Type) { case TreeContentType.Tree: { var dir = new TreeDirectory(Repository, item.Name, parent, name); trees.Add(item.Name, dir); parent.AddDirectory(dir); } break; case TreeContentType.Blob: { var blob = new TreeFile(Repository, item.Name, parent, FileStatus.Cached, name, ((BlobData)item).Size); parent.AddFile(blob); } break; case TreeContentType.Commit: { var commit = new TreeCommit(Repository, item.Name, parent, FileStatus.Cached, name); parent.AddCommit(commit); } break; } } }