private IEnumerable <ContentItem> UpdateAncestralTrailRecursive(ContentItem source, ContentItem destination) { source.AncestralTrail = destination.GetTrail(); foreach (var child in source.Children) { yield return(child); foreach (var descendant in UpdateAncestralTrailRecursive(child, source)) { yield return(descendant); } } }
public T Add <T>(Action <T> initializer, ContentItem parent) where T : ContentItem, new() { var c = new T { Parent = parent, AncestralTrail = parent.GetTrail(), ID = _repo.Count + 1 }; if (parent != null) { parent.Children.Add(c); } if (initializer != null) { initializer(c); } _repo.Add(c); return(c); }
public static ParameterCollection BelowOrSelf(ContentItem ancestorOrSelf) { return(Parameter.Equal("ID", ancestorOrSelf.ID) | Parameter.Like("AncestralTrail", ancestorOrSelf.GetTrail() + "%")); }
public static Parameter Below(ContentItem ancestor) { return(Parameter.Like("AncestralTrail", ancestor.GetTrail() + "%")); }
public static int CountDescendants(this IRepository <ContentItem> repository, ContentItem ancestor) { return((int)repository.Count(Parameter.Like("AncestralTrail", ancestor.GetTrail() + "%"))); }
public virtual void AddCacheInvalidation(ContentItem item, HttpResponse response) { switch (invalidationMode) { case OutputCacheInvalidationMode.All: AddCacheDependency(response, new ContentCacheDependency(persister)); break; case OutputCacheInvalidationMode.IgnoreChanges: AddCacheDependency(response, null); break; case OutputCacheInvalidationMode.Page: if (item == null) { return; } AddCacheDependency(response, new PageContentCacheDependency(persister, item.ID)); break; case OutputCacheInvalidationMode.Site: case OutputCacheInvalidationMode.SiteSection: if (item == null) { return; } var ancestors = Find.EnumerateParents(item, null, includeSelf: true); ContentItem invalidateBelow = null; foreach (var ancestor in ancestors) { if (ancestor is IStartPage) { if (invalidationMode == OutputCacheInvalidationMode.Site) { invalidateBelow = ancestor; } break; } invalidateBelow = ancestor; } AddCacheDependency(response, new SectionContentCacheDependency(persister, invalidateBelow.GetTrail())); break; default: throw new NotSupportedException("Unsupported cache invalidation mode " + invalidationMode); } }
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 static IQueryable <TSource> WhereDescendantOrSelf <TSource>(this IQueryable <TSource> source, ContentItem ancestor) where TSource : ContentItem { var trail = ancestor.GetTrail(); return(source.Where(ci => ci.AncestralTrail.StartsWith(trail) || ci == ancestor)); }
public static IQueryAction IsDescendant(this IQueryBuilder builder, ContentItem ancestor) { return builder.AncestralTrail.Like(ancestor.GetTrail() + "%"); }
private void SetChildren(ContentItem item) { item.Children = new ItemList(() => database.GetCollection<ContentItem>().Find(Query.EQ("AncestralTrail", item.GetTrail()))); }
private void SetChildren(ContentItem item) { item.Children = new ItemList(() => database.GetCollection <ContentItem>().Find(Query.EQ("AncestralTrail", item.GetTrail()))); }
public static IQueryAction IsAncestorOrSelf(this IQueryBuilder builder, ContentItem descendant) { return(builder.ID.In(descendant.GetTrail().Split('/').Where(id => !string.IsNullOrEmpty(id)).Select(id => int.Parse(id)).Union(new [] { descendant.ID }).ToArray())); }
public static IQueryAction IsDescendantOrSelf(this IQueryBuilder builder, ContentItem ancestor) { return(builder.OpenBracket().AncestralTrail.Like(ancestor.GetTrail() + "%").Or.ID.Eq(ancestor.ID).CloseBracket()); }
public static IQueryAction IsDescendant(this IQueryBuilder builder, ContentItem ancestor) { return(builder.AncestralTrail.Like(ancestor.GetTrail() + "%")); }
public static Parameter Below(ContentItem ancestor) { return Parameter.Like("AncestralTrail", ancestor.GetTrail() + "%"); }
public static ParameterCollection BelowOrSelf(ContentItem ancestorOrSelf) { return Parameter.Equal("ID", ancestorOrSelf.ID) | Parameter.Like("AncestralTrail", ancestorOrSelf.GetTrail() + "%"); }
public static IQueryAction IsDescendantOrSelf(this IQueryBuilder builder, ContentItem ancestor) { return builder.OpenBracket().AncestralTrail.Like(ancestor.GetTrail() + "%").Or.ID.Eq(ancestor.ID).CloseBracket(); }
private IEnumerable<ContentItem> UpdateAncestralTrailRecursive(ContentItem source, ContentItem destination) { source.AncestralTrail = destination.GetTrail(); foreach (var child in source.Children) { yield return child; foreach (var descendant in UpdateAncestralTrailRecursive(child, source)) yield return descendant; } }
public static IQueryAction IsAncestorOrSelf(this IQueryBuilder builder, ContentItem descendant) { return builder.ID.In(descendant.GetTrail().Split('/').Where(id => !string.IsNullOrEmpty(id)).Select(id => int.Parse(id)).Union(new [] { descendant.ID }).ToArray()); }