コード例 #1
0
ファイル: Tree.cs プロジェクト: wrohrbach/n2cms
        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();
            }
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
ファイル: QueryBuilder.cs プロジェクト: amarwadi/n2cms
        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);
        }
コード例 #6
0
ファイル: New.aspx.cs プロジェクト: JohnsonYuan/n2cms
        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;
        }