using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.Serialization;
namespace WcfControlMonitorWebLib
{
///
/// 树结构
///
/// 树中元素的类型
[DataContract]
public sealed class Tree
{
///
/// 构造函数
///
public Tree() { }
///
/// 构造函数
///
/// 数据元素
public Tree(T data)
{
Data = data;
}
///
/// 构造函数
///
/// 包含用于标识层级关系属性的数据集合
/// 数据标识属性
/// 层级标识属性
public Tree(IEnumerable items, string keyField, string parentField)
{
if (items != null)
{
Type type = typeof(T);
PropertyInfo keyProperty = type.GetProperty(keyField);
PropertyInfo parentProperty = type.GetProperty(parentField);
Dictionary