Exemple #1
0
 internal void RemoveCommit(TreeCommit commit)
 {
     if (_commits.Remove(commit))
     {
         commit.Parent = null;
         OnCommitDeleted(commit);
     }
 }
Exemple #2
0
        private void OnCommitDeleted(TreeCommit commit)
        {
            var handler = CommitDeleted;

            if (handler != null)
            {
                handler(this, new TreeCommitEventArgs(commit));
            }
        }
Exemple #3
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 #4
0
 private void OnCommitDeleted(TreeCommit commit)
 {
     var handler = CommitDeleted;
     if(handler != null) handler(this, new TreeCommitEventArgs(commit));
 }
Exemple #5
0
 internal void RemoveCommit(TreeCommit commit)
 {
     if(_commits.Remove(commit))
     {
         commit.Parent = null;
         OnCommitDeleted(commit);
     }
 }
Exemple #6
0
 internal void AddCommit(TreeCommit commit)
 {
     commit.Parent = this;
     _commits.Add(commit);
     OnCommitAdded(commit);
 }
Exemple #7
0
 internal void AddCommit(TreeCommit commit)
 {
     commit.Parent = this;
     _commits.Add(commit);
     OnCommitAdded(commit);
 }
Exemple #8
0
 private void OnCommitDeleted(TreeCommit commit)
 {
     CommitDeleted?.Invoke(this, new TreeCommitEventArgs(commit));
 }
Exemple #9
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;
         }
     }
 }