Ejemplo n.º 1
0
        private TreeNode ConvertToTreeNode(BjSJsonArray arr, string name)
        {
            TreeNode root = new TreeNode(String.Format(String.IsNullOrEmpty(name) ? "Array[{1}]" : "\"{0}\" : Array[{1}]", name, arr.Count));

            root.ImageIndex         = 1;
            root.SelectedImageIndex = 1;

            for (int i = 0; i < arr.Count; i++)
            {
                var obj = arr[i];
                switch (BjSJsonHelper.GetValueKind(obj))
                {
                case BjSJsonValueKind.Object:
                    root.Nodes.Add(ConvertToTreeNode(obj as BjSJsonObject, i.ToString()));
                    break;

                case BjSJsonValueKind.Array:
                    root.Nodes.Add(ConvertToTreeNode(obj as BjSJsonArray, i.ToString()));
                    break;

                case BjSJsonValueKind.String:
                    root.Nodes.Add(new TreeNode(String.Format("{0} : \"{1}\"", i, obj))
                    {
                        ImageIndex = 2, SelectedImageIndex = 2
                    });
                    break;

                case BjSJsonValueKind.Number:
                    root.Nodes.Add(new TreeNode(String.Format("{0} : {1}", i, obj))
                    {
                        ImageIndex = 3, SelectedImageIndex = 3
                    });
                    break;

                case BjSJsonValueKind.Boolean:
                    root.Nodes.Add(new TreeNode(String.Format("{0} : {1}", i, obj))
                    {
                        ImageIndex = 4, SelectedImageIndex = 4
                    });
                    break;

                case BjSJsonValueKind.Null:
                    root.Nodes.Add(new TreeNode(String.Format("{0} : null", i))
                    {
                        ImageIndex = 5, SelectedImageIndex = 5
                    });
                    break;

                default:
                    break;
                }
            }

            return(root);
        }
Ejemplo n.º 2
0
        private TreeNode ConvertToTreeNode(BjSJsonArray arr, string name)
        {
            TreeNode root = new TreeNode(String.Format(String.IsNullOrEmpty(name) ? "Array[{1}]" : "\"{0}\" : Array[{1}]", name, arr.Count));
            root.ImageIndex = 1;
            root.SelectedImageIndex = 1;

            for (int i = 0; i < arr.Count; i++)
            {
                var obj = arr[i];
                switch (BjSJsonHelper.GetValueKind(obj))
                {
                    case BjSJsonValueKind.Object:
                        root.Nodes.Add(ConvertToTreeNode(obj as BjSJsonObject, i.ToString()));
                        break;
                    case BjSJsonValueKind.Array:
                        root.Nodes.Add(ConvertToTreeNode(obj as BjSJsonArray, i.ToString()));
                        break;
                    case BjSJsonValueKind.String:
                        root.Nodes.Add(new TreeNode(String.Format("{0} : \"{1}\"", i, obj)) { ImageIndex = 2, SelectedImageIndex = 2 });
                        break;
                    case BjSJsonValueKind.Number:
                        root.Nodes.Add(new TreeNode(String.Format("{0} : {1}", i, obj)) { ImageIndex = 3, SelectedImageIndex = 3 });
                        break;
                    case BjSJsonValueKind.Boolean:
                        root.Nodes.Add(new TreeNode(String.Format("{0} : {1}", i, obj)) { ImageIndex = 4, SelectedImageIndex = 4 });
                        break;
                    case BjSJsonValueKind.Null:
                        root.Nodes.Add(new TreeNode(String.Format("{0} : null", i)) { ImageIndex = 5, SelectedImageIndex = 5 });
                        break;
                    default:
                        break;
                }
            }

            return root;
        }