private void WriteChildren(TextWriter writer, HierarchyNode <ContentItem> parent, bool renderUl) { IDisposable wrapper = null; foreach (var child in parent.Children) { if (!filter.Match(child.Current)) { continue; } if (renderUl && wrapper == null) { wrapper = TagWrapper.Begin("ul", child, tagModifier, writer); } using (TagWrapper.Begin("li", child, tagModifier, writer)) { linkWriter(child, writer); WriteChildren(writer, child, true); } } if (wrapper != null) { wrapper.Dispose(); } }
private static ContentItem Last(IList <ContentItem> children, ItemFilter filter) { for (int i = children.Count - 1; i >= 0; i--) { if (!filter.Match(children[i])) { continue; } return(children[i]); } return(null); }
private static T FilterWith <T>(this T item, ItemFilter filter) where T : ContentItem { if (item == null) { return(null); } if (filter.Match(item)) { return(item); } return(null); }
private TreeNode BuildNodesRecursive(HierarchyNode <ContentItem> navigator) { ContentItem item = navigator.Current; TreeNode node = new TreeNode(item, linkProvider(item).ToControl()); node.LiClass = classProvider(item); foreach (var childNavigator in navigator.Children) { if (!filter.Match(childNavigator.Current)) { continue; } TreeNode childNode = BuildNodesRecursive(childNavigator); node.Controls.Add(childNode); } return(node); }
private ItemList <T> ToListWithFillup <T>(IList <T> retrievedItems, ItemFilter filter, int maxRequeries) where T : ContentItem { ItemList <T> items = new ItemList <T>(); int totalRetrievedItems = 0; while (retrievedItems.Count > 0) { int addedCount = 0; foreach (var item in retrievedItems) { if (ReachedMaxResults(items.Count)) { break; } if (!filter.Match(item)) { continue; } ++addedCount; items.Add(item); } if (addedCount == retrievedItems.Count) { break; // we've already added all items down there } if (ReachedMaxResults(items.Count)) { break; // we've reached the items we need } if (--maxRequeries == 0) { break; } // try finding more items in the database totalRetrievedItems += retrievedItems.Count; retrievedItems = CreateQuery(selectHql, totalRetrievedItems + FirstResult, MaxResults, Cachable).List <T>(); } return(items); }
private static ContentItem Last(IList<ContentItem> children, ItemFilter filter) { for (int i = children.Count - 1; i >= 0; i--) { if (!filter.Match(children[i])) continue; return children[i]; } return null; }