Пример #1
0
 public static void AcceptVisitor(this BranchTree branch, IBranchTreeVisitor treeVisitor, int level = 0)
 {
     treeVisitor.Visit(branch, level);
     foreach (var childBranch in branch.ChildBranches)
     {
         childBranch.AcceptVisitor(treeVisitor, level + 1);
     }
 }
 public void Visit(BranchTree childBranch, int level)
 {
     if (Found == false
         && ((searchExactPath && searchPath.ToLower() == childBranch.Path.ToLower())
         || (!searchExactPath && searchPath.ToLower().IndexOf(childBranch.Path.ToLower()) == 0)))
     {
         Found = true;
     }
 }
Пример #3
0
        private BranchTree CreateBranchTree(string tfsPath, BranchTree parent = null)
        {
            var branchObject = MockRepository.GenerateStub<IBranchObject>();
            branchObject.Stub(m => m.Path).Return(tfsPath);

            var branchTree = new BranchTree(branchObject);

            if(parent != null)
                parent.ChildBranches.Add(branchTree);
            return branchTree;
        }
Пример #4
0
        public static IEnumerable <BranchTree> GetAllChildren(this BranchTree branch)
        {
            if (branch == null)
            {
                return(Enumerable.Empty <BranchTree>());
            }

            var childrenBranches = new List <BranchTree>(branch.ChildBranches);

            foreach (var childBranch in branch.ChildBranches)
            {
                childrenBranches.AddRange(childBranch.GetAllChildren());
            }
            return(childrenBranches);
        }
Пример #5
0
        public static IEnumerable <BranchTree> GetAllChildrenOfBranch(this BranchTree branch, string tfsPath)
        {
            if (branch == null)
            {
                return(Enumerable.Empty <BranchTree>());
            }

            if (string.Compare(branch.Path, tfsPath, StringComparison.InvariantCultureIgnoreCase) == 0)
            {
                return(branch.GetAllChildren());
            }

            var childrenBranches = new List <BranchTree>();

            foreach (var childBranch in branch.ChildBranches)
            {
                childrenBranches.AddRange(GetAllChildrenOfBranch(childBranch, tfsPath));
            }
            return(childrenBranches);
        }
 public BranchContainsPathVisitorTest()
 {
     branch = new BranchTree(new MockBranchObject { Path = @"$/Scratch/Source/Main" });
 }
Пример #7
0
            public void Visit(BranchTree branch, int level)
            {
                for (var i = 0; i < level; i++ )
                    _stdout.Write(" | ");
                
                _stdout.WriteLine();

                for (var i = 0; i < level - 1; i++)
                    _stdout.Write(" | ");

                if (level > 0)
                    _stdout.Write(" +-");

                _stdout.Write(" {0}", branch.Path);

                if (_tfsRemotes != null)
                {
                    var remote = _tfsRemotes.FirstOrDefault(r => r.TfsRepositoryPath == branch.Path);
                    if (remote != null)
                        _stdout.Write(" -> " + remote.Id);
                }

                if (branch.Path.Equals(_targetPath))
                    _stdout.Write(" [*]");

                _stdout.WriteLine();
            }
Пример #8
0
            public void Visit(BranchTree branch, int level)
            {
                var writer = new StringWriter();
                for (var i = 0; i < level; i++)
                    writer.Write(" | ");

                writer.WriteLine();

                for (var i = 0; i < level - 1; i++)
                    writer.Write(" | ");

                if (level > 0)
                    writer.Write(" +-");

                writer.Write(" {0}", branch.Path);

                if (_tfsRemotes != null)
                {
                    var remote = _tfsRemotes.FirstOrDefault(r => r.TfsRepositoryPath == branch.Path);
                    if (remote != null)
                        writer.Write(" -> " + remote.Id);
                }

                if (branch.Path.Equals(_targetPath))
                    writer.Write(" [*]");

                Trace.TraceInformation(writer.ToString());
            }