public static bool Expand(this ITreeSettings settings, ContentReference contentLink) { if (settings == null) { throw new ArgumentNullException(nameof(settings)); } return(!ContentReference.IsNullOrEmpty(contentLink) && (settings.PopulateEntireTree || settings.Expanded.Contains(contentLink)) && !settings.Collapsed.Contains(contentLink)); }
public virtual IContentRoot <T> Create <T>(ContentReference root, ITreeSettings settings) where T : IContent { if (settings == null) { throw new ArgumentNullException(nameof(settings)); } var activeLink = settings.IndicateActiveContent ? this.ContentRouteHelperContext.ContentRouteHelper.ContentLink : null; var activeLinkAncestors = (ContentReference.IsNullOrEmpty(activeLink) ? Enumerable.Empty <ContentReference>() : this.ContentLoader.GetAncestors(activeLink).Select(ancestor => ancestor.ContentLink)).ToArray(); T content = default; if (!ContentReference.IsNullOrEmpty(root)) { try { content = this.ContentLoader.Get <T>(root); if (this.Filters.AccessFilter.ShouldFilter(content)) { content = default; if (this.Logger.IsWarningEnabled()) { this.Logger.Warning("The current user do not have access to root \"{0}\".", root); } } } catch (Exception exception) { if (this.Logger.IsErrorEnabled()) { this.Logger.Error($"Could not get content for root \"{root}\".", exception); } } } else { if (this.Logger.IsDebugEnabled()) { this.Logger.Debug("The root is {0}.", root == null ? "null" : "empty"); } } return(new ContentRoot <T>(activeLink, activeLinkAncestors, root, this.ContentLoader, this.LoggerFactory.Create(typeof(ContentNode <T>).FullName), settings, content)); }
public ExpandingEventArgs(IContentNode node, ITreeSettings settings) { this.Node = node ?? throw new ArgumentNullException(nameof(node)); this.Settings = settings ?? throw new ArgumentNullException(nameof(settings)); }
public virtual IEnumerable <IContentRoot <T> > Create <T>(IEnumerable <ContentReference> roots, ITreeSettings settings) where T : IContent { if (settings == null) { throw new ArgumentNullException(nameof(settings)); } foreach (var root in this.DuplicateHandledRoots(roots, settings)) { yield return(this.Create <T>(root, settings)); } }
public virtual IEnumerable <IContentRoot <IContent> > Create(IEnumerable <ContentReference> roots, ITreeSettings settings) { return(this.Create <IContent>(roots, settings)); }
public virtual IContentRoot <IContent> Create(ContentReference root, ITreeSettings settings) { return(this.Create <IContent>(root, settings)); }
public ContentRoot(ContentReference activeLink, IEnumerable <ContentReference> activeLinkAncestors, ContentReference contentLink, IContentLoader contentLoader, ILogger logger, ITreeSettings settings, T value) : base(activeLink, activeLinkAncestors, contentLoader, logger, settings) { if (contentLink == null) { throw new ArgumentNullException(nameof(contentLink)); } if (ContentReference.IsNullOrEmpty(contentLink)) { throw new ArgumentException("The content-link can not be empty.", nameof(contentLink)); } this.ContentLink = contentLink.ToReferenceWithoutVersion(); this.Value = value; }
public ContentNode(ContentReference activeLink, IEnumerable <ContentReference> activeLinkAncestors, IContentLoader contentLoader, ILogger logger, IContentNode <T> parent, ITreeSettings settings, T value) : this(activeLink, activeLinkAncestors, contentLoader, logger, settings) { this.ContentLink = value?.ContentLink?.ToReferenceWithoutVersion(); this.Parent = parent ?? throw new ArgumentNullException(nameof(parent)); if (value == null) { throw new ArgumentNullException(nameof(value)); } this.Value = value; }
protected internal ContentNode(ContentReference activeLink, IEnumerable <ContentReference> activeLinkAncestors, IContentLoader contentLoader, ILogger logger, ITreeSettings settings) { this.ActiveLink = activeLink; this.ActiveLinkAncestors = activeLinkAncestors ?? Enumerable.Empty <ContentReference>(); this.ContentLoader = contentLoader ?? throw new ArgumentNullException(nameof(contentLoader)); this.Logger = logger ?? throw new ArgumentNullException(nameof(logger)); this.Settings = settings ?? throw new ArgumentNullException(nameof(settings)); }