private static IEnumerable <T> InternalFindAllNonSiteDescendentsOfRoot <T>(AccessFilter accessFilter,
                                                                                   PublishedFilter publishedFilter, Func <T, bool> predicate = null)
            where T : ContentItem
        {
            var root     = FindLanguageIntersection();
            var prefixes = Finder().FindAllDescendentsOf <StartPage>(root).Select(i => i.GetTrail()).ToList();
            var result   = Finder().FindAllDescendentsOf <T>(root, accessFilter, publishedFilter);

            if (predicate != null)
            {
                result = result.Where(predicate);
            }

            // Exclude any items that are children of start pages.
            return(result.Where(r => !prefixes.Any(pref => r.AncestralTrail.StartsWith(pref))));
        }
예제 #2
0
        public void Test_PublishedFilter_Filters()
        {
            var pub = new Article {
                IsPublished = true, Id = 1
            };
            var notPub = new Article {
                IsPublished = false, Id = 2
            };

            var filter = new PublishedFilter();

            Assert.IsTrue(filter.Matches(pub));
            Assert.IsFalse(filter.Matches(notPub));

            var filtered = filter.FilterArticles(pub, notPub);

            Assert.AreEqual(1, filtered.Length);
            Assert.AreEqual(1, filtered[0].Id);
        }
예제 #3
0
 public bool IsPublished(ContentItem item)
 {
     return(PublishedFilter.IsPublished(item));
 }
        public IEnumerable <T> FindAllDescendentsOf <T>(ContentItem ancestor, AccessFilter accessFilter = null, PublishedFilter publishedFilter = null) where T : ContentItem
        {
            if (accessFilter == null && publishedFilter == null)
            {
                return(_itemFinder.AllOfType <T>().Where(i => i.AncestralTrail.StartsWith(ancestor.GetTrail())));
            }

            var filter = new AllFilter(accessFilter ?? new AccessFilter(), publishedFilter ?? new PublishedFilter());

            return(_itemFinder.AllOfType <T>().Where(i => i.AncestralTrail.StartsWith(ancestor.GetTrail())).Where(filter.Match));
        }
        public IEnumerable <T> FindAll <T>(AccessFilter accessFilter, PublishedFilter publishedFilter) where T : ContentItem
        {
            var filter = new AllFilter(accessFilter ?? new AccessFilter(), publishedFilter ?? new PublishedFilter());

            return(_itemFinder.AllOfType <T>().Where(filter.Match));
        }