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; } }
// 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); }
public TreeManager(Leaf leaf, TBranch branchType) { _rootNode = CreateRootBranch(leaf, branchType); }
public Branch(TBranch branchType) { _branchType = branchType; }
public TBranch Start <TBranch>() where TBranch : IBranchHandler, new() { TBranch handler = new TBranch() { } }