Exemple #1
0
        private void InvokeRemovedFile(TreeFile file)
        {
            file.MarkAsDeleted();
            var handler = file.StagedStatus == StagedStatus.Staged ? RemovedStagedFile : RemovedUnstagedFile;

            handler?.Invoke(this, new TreeFileEventArgs(file));
        }
Exemple #2
0
        private void OnFileDeleted(TreeFile file)
        {
            var handler = FileDeleted;

            if (handler != null)
            {
                handler(this, new TreeFileEventArgs(file));
            }
        }
Exemple #3
0
        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;
        }
Exemple #4
0
        private void InvokeFileAdded(TreeFile file)
        {
            var handler = FileAdded;

            if (handler != null)
            {
                handler(this, new TreeFileEventArgs(file));
            }
        }
Exemple #5
0
        private void InvokeNewFile(TreeFile file)
        {
            var handler = file.StagedStatus == StagedStatus.Staged ? NewStagedFile : NewUnstagedFile;

            if (handler != null)
            {
                handler(this, new TreeFileEventArgs(file));
            }
        }
Exemple #6
0
        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);
            }
        }
Exemple #7
0
        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;
                }
            }
        }
Exemple #8
0
        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;
        }
Exemple #9
0
 public TreeFileEventArgs(TreeFile file)
 {
     File = file;
 }
Exemple #10
0
 private void OnFileDeleted(TreeFile file)
 {
     var handler = FileDeleted;
     if(handler != null) handler(this, new TreeFileEventArgs(file));
 }
Exemple #11
0
 private void InvokeFileAdded(TreeFile file)
 {
     var handler = FileAdded;
     if(handler != null) handler(this, new TreeFileEventArgs(file));
 }
Exemple #12
0
 internal void RemoveFile(TreeFile file)
 {
     file.Parent = null;
     _files.Remove(file);
     OnFileDeleted(file);
 }
Exemple #13
0
 private void InvokeRemovedFile(TreeFile file)
 {
     file.MarkAsDeleted();
     var handler = file.StagedStatus == StagedStatus.Staged ? RemovedStagedFile : RemovedUnstagedFile;
     if(handler != null) handler(this, new TreeFileEventArgs(file));
 }
Exemple #14
0
 internal void RemoveFile(TreeFile file)
 {
     file.Parent = null;
     _files.Remove(file);
     OnFileDeleted(file);
 }
Exemple #15
0
 internal void AddFile(TreeFile file)
 {
     file.Parent = this;
     _files.Add(file);
     InvokeFileAdded(file);
 }
Exemple #16
0
 private void OnFileDeleted(TreeFile file)
 {
     FileDeleted?.Invoke(this, new TreeFileEventArgs(file));
 }
Exemple #17
0
 private void InvokeFileAdded(TreeFile file)
 {
     FileAdded?.Invoke(this, new TreeFileEventArgs(file));
 }
Exemple #18
0
 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);
     }
 }
Exemple #19
0
 private void InvokeNewFile(TreeFile file)
 {
     var handler = file.StagedStatus == StagedStatus.Staged ? NewStagedFile : NewUnstagedFile;
     if(handler != null) handler(this, new TreeFileEventArgs(file));
 }
Exemple #20
0
 internal void AddFile(TreeFile file)
 {
     file.Parent = this;
     _files.Add(file);
     InvokeFileAdded(file);
 }
Exemple #21
0
 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;
         }
     }
 }