Пример #1
0
        /// <summary>
        /// Create a TreeNode and its subtrees for the <paramref name="obj"/> instance beeing a <see cref="JProperty"/> instance.
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="depth"></param>
        /// <returns></returns>
        public static TreeNode Create(JProperty obj, int depth)
        {
            var node = new JPropertyTreeNode(obj);

            if (depth != 1)
            {
                int remainingDepth = (depth == UnlimitedDepth ? UnlimitedDepth : depth - 1);
                node.Nodes.AddRange(obj
                   .Select(o => Create((dynamic)o, remainingDepth))
                   .Cast<TreeNode>()
                   .ToArray()
                   );
            }

            return node;
        }