Example #1
0
 public ActionResult GetBranch()
 {
     BranchBLL bBll = new BranchBLL();
     List<Branch> branchList = bBll.GetEntitys(t=>t.sort);
     List<BranchTree> list = new List<BranchTree>();
     foreach (Branch branch in branchList)
     {
         if (branch.parent == 0)
         {
             BranchTree bTree = new BranchTree();
             bTree.Id = branch.Id;
             bTree.branchName = branch.branchName;
             bTree.parent = branch.parent;
             bTree.sort = branch.sort;
             bTree.telPhone = branch.telPhone;
             bTree.fax = branch.fax;
             bTree.expanded = true;
             bTree.leaf = false;
             bTree.children = BranchEach(branchList, branch);
             list.Add(bTree);
         }
     }
     string resJson = Common.Common.JsonSerialize(list);
     resJson = "{'checked':false,'children':" + resJson;
     resJson += "}";
     return Content(resJson);
 }
Example #2
0
        public ActionResult GetBranch()
        {
            BranchBLL         bBll       = new BranchBLL();
            List <Branch>     branchList = bBll.GetEntitys(t => t.sort);
            List <BranchTree> list       = new List <BranchTree>();

            foreach (Branch branch in branchList)
            {
                if (branch.parent == 0)
                {
                    BranchTree bTree = new BranchTree();
                    bTree.Id         = branch.Id;
                    bTree.branchName = branch.branchName;
                    bTree.parent     = branch.parent;
                    bTree.sort       = branch.sort;
                    bTree.telPhone   = branch.telPhone;
                    bTree.fax        = branch.fax;
                    bTree.expanded   = true;
                    bTree.leaf       = false;
                    bTree.children   = BranchEach(branchList, branch);
                    list.Add(bTree);
                }
            }
            string resJson = Common.Common.JsonSerialize(list);

            resJson  = "{'checked':false,'children':" + resJson;
            resJson += "}";
            return(Content(resJson));
        }
 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;
     }
 }
Example #4
0
        private void PrintElement(int shift, Tree element)
        {
            BranchTree temp = element as BranchTree;

            Console.WriteLine("{0}{1}", new string(' ', shift), temp.BranchValue);
            foreach (var child in element.Node)
            {
                PrintElement(shift + 2, child);
            }
        }
        private void CreateBranches()
        {
            var rootNode = new TreeNode(Strings.Branches)
            {
                ImageKey         = nameof(Images.BranchLocalRoot),
                SelectedImageKey = nameof(Images.BranchLocalRoot),
            };

            _branchesTree = new BranchTree(rootNode, UICommandsSource, _aheadBehindDataProvider);
        }
Example #6
0
 private void AddBranches()
 {
     _branchesTreeRootNode = new TreeNode(Strings.Branches)
     {
         ImageKey         = nameof(Images.BranchLocalRoot),
         SelectedImageKey = nameof(Images.BranchLocalRoot),
     };
     _branchesTree = new BranchTree(_branchesTreeRootNode, UICommandsSource, _aheadBehindDataProvider);
     AddTree(_branchesTree, 0);
     _searchResult = null;
 }
Example #7
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);
        }
 private Branch FindBranch(SyntaxNode expression, out Condition inlineCondition)
 {
     // First search any lambdas. Those are kept separate since they could run at any time.
     foreach (var lambda in Lambdas)
     {
         Branch branch = lambda.FindBranch(expression, out inlineCondition);
         if (branch != null)
         {
             return(branch);
         }
     }
     // If not in a lambda, then search the full method body.
     return(BranchTree.FindBranch(expression, out inlineCondition));
 }
Example #9
0
        private BranchTree CreateBranchTree(string tfsPath, BranchTree parent = null)
        {
            var branchObject = new Mock <IBranchObject>();

            branchObject.Setup(m => m.Path).Returns(tfsPath);

            var branchTree = new BranchTree(branchObject.Object);

            if (parent != null)
            {
                parent.ChildBranches.Add(branchTree);
            }
            return(branchTree);
        }
Example #10
0
        private MenuItem[] GenerateMenuItems(string solutionDir)
        {
            using var repo = Git.OpenRepository(solutionDir);
            if (repo == null)
            {
                return(MakeError(Strings.could_not_find_valid_git_repository));
            }
            var config  = Config.Load(solutionDir);
            var current = StringEx.OrDefault(config.TargetBranch, repo.Head.FriendlyName);

            if (current == null)
            {
                return(MakeError(Strings.could_not_find_valid_git_repository));
            }
            var tree = BranchTree.From(repo.Branches.Select(a => a.FriendlyName));

            return(tree.ToMenuItems(current));
        }
Example #11
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());
            }
 /// <summary>
 /// Checks if there were any assignments to null on the symbol that is being checked in <paramref name="expression"/>
 /// </summary>
 /// <param name="expression">The expression containing the symbol being validated</param>
 /// <param name="assignmentsForExpression">All assignments to the symbol being validated</param>
 /// <param name="branchWithMatchingCondition">The branch with the condition that proves the expression is valid</param>
 /// <returns></returns>
 private bool NullAssignmentsAreInPath(
     SyntaxNode expression,
     List <Assignment> assignmentsForExpression,
     Branch branchWithMatchingCondition)
 {
     foreach (var assignment in assignmentsForExpression.Where(i => i.Value != ValueType.NotNull))
     {
         var assignmentBranch = BranchTree.FindBranch(assignment.Expression, out var trash);
         if (assignmentBranch != null)
         {
             if (branchWithMatchingCondition == assignmentBranch ||
                 branchWithMatchingCondition.IsParentOf(assignmentBranch))
             {
                 if (branchWithMatchingCondition.Condition.IsWhile(assignment.Symbol, model))
                 {
                     return(assignment.Expression.SpanStart < expression.SpanStart);
                 }
                 return(true);
             }
         }
     }
     return(false);
 }
Example #13
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();
            }
 public BranchContainsPathVisitorTest()
 {
     branch = new BranchTree(new MockBranchObject {
         Path = @"$/Scratch/Source/Main"
     });
 }