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);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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;
        }
Beispiel #5
0
        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;
        }