public IList <CategoryTreeNode> PathFromRoot() { var path = new List <CategoryTreeNode>(); CategoryTreeNode entry = this; while (entry != null) { path.Add(entry); entry = entry.Parent; } path.Reverse(); return(path); }
private CategoryTreeNode CloneEntry(CategoryTreeNode entry, CategoryTreeNode parent) { var clone = new CategoryTreeNode { Id = entry.Id, Name = entry.Name, Parent = parent }; foreach (var child in entry.Children) { clone.Children.Add(CloneEntry(child, entry)); } return(clone); }
static CategoryTreeNode BuildEntry(Category category, IEnumerable <Category> all) { var entry = new CategoryTreeNode { Id = category.Id, Name = category.Name, Description = category.Description, Photo = category.Photo, CustomFields = category.CustomFields.ToDictionary(f => f.Name, f => f.Value) }; foreach (var child in all.Where(c => c.Parent != null && c.Parent.Id == category.Id)) { var childEntry = BuildEntry(child, all); entry.Children.Add(childEntry); childEntry.Parent = entry; } return(entry); }
private CategoryTreeNode CloneEntry(CategoryTreeNode entry, CategoryTreeNode parent) { var clone = new CategoryTreeNode { Id = entry.Id, Name = entry.Name, Parent = parent }; foreach (var child in entry.Children) { clone.Children.Add(CloneEntry(child, entry)); } return clone; }
static CategoryTreeNode BuildEntry(Category category, IEnumerable<Category> all) { var entry = new CategoryTreeNode { Id = category.Id, Name = category.Name, Description = category.Description, Photo = category.Photo, CustomFields = category.CustomFields.ToDictionary(f => f.Name, f => f.Value) }; foreach (var child in all.Where(c => c.Parent != null && c.Parent.Id == category.Id)) { var childEntry = BuildEntry(child, all); entry.Children.Add(childEntry); childEntry.Parent = entry; } return entry; }