using System; using System.Collections.Concurrent; using System.Linq; using System.Net.Http.Formatting; using Umbraco.Core; using Umbraco.Web.Models.Trees; using Umbraco.Web.Mvc; namespace Umbraco.Web.Trees { /// /// The base controller for all tree requests /// public abstract class TreeController : TreeControllerBase { private readonly TreeAttribute _attribute; protected TreeController() { //Locate the tree attribute var treeAttributes = GetType() .GetCustomAttributes(typeof(TreeAttribute), false) .OfType() .ToArray(); if (treeAttributes.Any() == false) { throw new InvalidOperationException("The Tree controller is missing the " + typeof(TreeAttribute).FullName + " attribute"); } //assign the properties of this object to those of the metadata attribute _attribute = treeAttributes.First(); } /// /// The name to display on the root node /// public override string RootNodeDisplayName { get { return _attribute.Title; } } /// /// Gets the current tree alias from the attribute assigned to it. /// public override string TreeAlias { get { return _attribute.Alias; } } } }