using System.Runtime.Serialization;
namespace Umbraco.Web.Models.Trees
{
///
/// A special tree node that represents the section root node for any section.
///
///
/// This is required to return the tree data for a given section. Some sections may only contain one tree which means it's section
/// root should also display a menu, whereas other sections have multiple trees and the section root shouldn't display a menu.
///
/// The section root also contains an explicit collection of children.
///
[DataContract(Name = "node", Namespace = "")]
public sealed class SectionRootNode : TreeNode
{
public static SectionRootNode CreateMultiTreeSectionRoot(string nodeId, TreeNodeCollection children)
{
return new SectionRootNode(nodeId, "", "")
{
IsContainer = true,
Children = children
};
}
public static SectionRootNode CreateSingleTreeSectionRoot(string nodeId, string getChildNodesUrl, string menuUrl, string title, TreeNodeCollection children)
{
return new SectionRootNode(nodeId, getChildNodesUrl, menuUrl)
{
Children = children,
Title = title
};
}
private SectionRootNode(string nodeId, string getChildNodesUrl, string menuUrl)
: base(nodeId, getChildNodesUrl, menuUrl)
{
//default to false
IsContainer = false;
}
[DataMember(Name = "isContainer")]
public bool IsContainer { get; private set; }
[DataMember(Name = "children")]
public TreeNodeCollection Children { get; private set; }
}
}