private void GerenateForParent(ContentPageTreeItem parent)
        {
            var children = this.provider.GetChildren(parent.Page.Id);

            if (children == null || !children.Any())
            {
                return;
            }

            foreach (var child in children)
            {
                if (!this.cache.ContainsKey(child.Id))
                {
                    var item = new ContentPageTreeItem(child, parent);
                    parent.Children.Add(item);
                    this.cache.Add(child.Id, item);
                }
                else
                {
                    // Cyclic dependecies has been encountered.
                    // Fixing the database by assigning the page in to fake root.
                    this.provider.TrashPage(child.Id);
                }
            }

            foreach (var child in parent.Children)
            {
                this.GerenateForParent(child);
            }
        }
        public ContentPageTreeItem LookupPage(Guid id, ContentPageTreeItem current)
        {
            if (current.Page.Id == id)
            {
                return(current);
            }

            foreach (var child in current.Children)
            {
                var result = LookupPage(id, child);
                if (result != null)
                {
                    return(result);
                }
            }

            return(null);
        }
 public ContentPageTreeItem(ContentPage page, ContentPageTreeItem parent)
 {
     this.Children = new List <ContentPageTreeItem>();
     this.Page     = page;
     this.Parent   = parent;
 }