using System.Collections.Generic; using System.Runtime.Serialization; namespace Tree { [DataContract] public class TreeNodeDataArray { private readonly List treeNodeDatas = new List(); [DataMember(Order = 1)] public List TreeNodeDatas { get { return this.treeNodeDatas; } } private readonly Dictionary treeNodeDict = new Dictionary(); public void Init() { foreach (TreeNodeData nodeData in this.treeNodeDatas) { this.treeNodeDict[nodeData.Id] = nodeData; } } public void Add(TreeNodeData treeNodeData) { this.treeNodeDatas.Add(treeNodeData); } public TreeNodeData this[int id] { get { return this.treeNodeDict[id]; } } } }