Beispiel #1
0
        private void addNode(CPKNode node, TreeNode treeParent)
        {
            var root = treeParent.Nodes.Add(node.Name + (node.SerializedLength < 40 ? " = " + node.Value.ToString() : "") +  string.Format(" [{0}, {1}]", node.Type, formatSize(node.SerializedLength)));
            root.Tag = node;

            if ((node.Type & CPKValueType.List) == CPKValueType.List) {
                foreach (var child in node.Value.Nodes)
                    addNode(child.Value, root);
            }
            if ((node.Type & CPKValueType.Array) == CPKValueType.Array) {
                for (var i = 0; i < node.Value.Items.Count; ++i) {
                    addValue(i, node.Value.Items[i], root);
                }
            }

            root.Expand();
        }
Beispiel #2
0
 /// <summary>
 /// 返回或设置指定名称的节点的值。
 /// </summary>
 /// <param name="nodeName"></param>
 /// <returns></returns>
 public CPKValue this[string nodeName]
 {
     get {
         CPKNode ret;
         if (this.Nodes.TryGetValue(nodeName, out ret)) {
             return ret.Value;
         }
         ret = new CPKNode(nodeName, (object)null);
         this.Nodes[nodeName] = ret;
         return ret.Value;
     }
     set {
         this.Nodes[nodeName] = new CPKNode(nodeName, value);
     }
 }