53 lines
1.5 KiB
C#
53 lines
1.5 KiB
C#
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
|
|
{
|
|
/// <summary>
|
|
/// The base controller for all tree requests
|
|
/// </summary>
|
|
public abstract class TreeController : TreeControllerBase
|
|
{
|
|
private readonly TreeAttribute _attribute;
|
|
|
|
protected TreeController()
|
|
{
|
|
//Locate the tree attribute
|
|
var treeAttributes = GetType()
|
|
.GetCustomAttributes(typeof(TreeAttribute), false)
|
|
.OfType<TreeAttribute>()
|
|
.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();
|
|
}
|
|
|
|
/// <summary>
|
|
/// The name to display on the root node
|
|
/// </summary>
|
|
public override string RootNodeDisplayName
|
|
{
|
|
get { return _attribute.Title; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the current tree alias from the attribute assigned to it.
|
|
/// </summary>
|
|
public override string TreeAlias
|
|
{
|
|
get { return _attribute.Alias; }
|
|
}
|
|
|
|
}
|
|
}
|