private void SaveBranch(IPropertyBranch branch)
        {
            using (DatabaseContext context = CreateDatabaseContext())
            {
                BranchRepository branchRepository = new BranchRepository(context);
                TBranch          existingBranch   = branchRepository.GetBranch(branch.BranchId, branch.Type);

                if (existingBranch == null)
                {
                    existingBranch = context.Branch.Add(new TBranch
                    {
                        BranchId  = branch.BranchId,
                        Name      = branch.Name,
                        Reference = branch.Reference,
                        Type      = branch.Type
                    });
                }
                else
                {
                    existingBranch.Name      = branch.Name;
                    existingBranch.Reference = branch.Reference;
                }

                context.SaveChanges();

                // set the branchGuid back to the calling branch
                branch.BranchGuid = existingBranch.BranchGuid;
            }
        }
示例#2
0
        // Root branch will default to selector type if its not provided.
        private static Branch CreateRootBranch(Leaf leaf, TBranch branchType = TBranch.Selector)
        {
            if (leaf == null)
            {
                throw new ArgumentNullException("Node cannot be null.");
            }

            Branch root = new Branch(branchType);

            root.Children.Enqueue(leaf);

            return(root);
        }
示例#3
0
 public TreeManager(Leaf leaf, TBranch branchType)
 {
     _rootNode = CreateRootBranch(leaf, branchType);
 }
示例#4
0
 public Branch(TBranch branchType)
 {
     _branchType = branchType;
 }
示例#5
0
 public TBranch Start <TBranch>() where TBranch : IBranchHandler, new()
 {
     TBranch handler = new TBranch()
     {
     }
 }