private void AddToRoot(AuthTree root, List <string> strs, AuthLeaf leaf) { var currentItem = root; foreach (var str in strs) { AuthTree founded = null; foreach (var child in currentItem.Children) { if (String.Compare(child.Title, str, true) == 0) { founded = child as AuthTree; if (founded != null) { break; } } } if (founded == null) { founded = new AuthTree(); founded.Title = str; items.Add(founded.Id, founded); currentItem.Children.Add(founded); founded.Parent = currentItem; } currentItem = founded; } currentItem.Children.Add(leaf); leaf.Parent = currentItem; }
private String BuildGroup() { var path = new List <String>(); AuthTree current = this.Parent; path.Add(current.Title); while (current.Parent != null) { current = current.Parent; if (current == null) { break; } path.Add(current.Title); } //Remove root path.RemoveAt(path.Count - 1); path.Reverse(); //Remove last child (used directly from parent) path.RemoveAt(path.Count - 1); return(String.Join("/", path)); }