private static void Add(int treeDepth, List <FolderItem> items, NamedMenuItem toAdd) { var currentTreeItem = toAdd.Location.Folders.Skip(treeDepth).FirstOrDefault(); var contained = (from a in items where a.Name == currentTreeItem select a).FirstOrDefault(); //If there is no contained item, add the current tree as far as it goes, then add the item to the end of the list. if (contained == null || currentTreeItem == null) { RecursivePerformAdd(treeDepth, items, toAdd); } else { Add(treeDepth + 1, contained.Children, toAdd); } }
private static void RecursivePerformAdd(int treeDepth, List <FolderItem> items, NamedMenuItem toAdd) { IEnumerable <string> tree = toAdd.Location.Folders.Skip(treeDepth); if (tree.Any()) { var item = new MidFolderItem(tree.First()); items.Add(item); RecursivePerformAdd(treeDepth + 1, item.Children, toAdd); } else { items.Add(new EndFolderItem(toAdd)); } }
public void AddMenuItem(NamedMenuItem item) { collection.Add(item); }
public void Add(NamedMenuItem item) { Add(0, list, item); }
public EndFolderItem(NamedMenuItem item) { this.Item = item; }