コード例 #1
0
        /// <summary>
        /// Returns a clone of this nested dictionary and all its descendants.
        /// </summary>
        /// <returns>A clone of this nested dictionary and all its descendants.</returns>
        public NestedDictionary Clone()
        {
            NestedDictionary p_clone = new NestedDictionary();

            foreach (KeyValuePair <string, NestedDictionaryNode> ndf_entry in this)
            {
                p_clone.Add(ndf_entry.Key, ndf_entry.Value.Clone());
            }
            return(p_clone);
        }
コード例 #2
0
        public static NestedDictionary Serialize <T>(T value)
        {
            var ndf = new NestedDictionary();

            ndf.Add("", new NestedDictionaryNode()
            {
                Key = ""
            });
            if (value != null)
            {
                Serializer <T> .Serialize(ndf, value);
            }
            return(ndf);
        }
コード例 #3
0
        private static void AddNode(List <NestedDictionary> p_ndf, ref NestedDictionary p_current_dict, ref NestedDictionaryNode p_current_node)
        {
            string p_node_key = p_current_node.Key;

            if (p_node_key == null)
            {
                return;                     // only occurs should the "node" be a reference
            }
            if (!p_current_dict.ContainsKey(p_node_key))
            {
                p_current_dict.Add(p_node_key, p_current_node);
            }
            else
            {
                p_ndf.Add(p_current_dict);
                p_current_dict = new NestedDictionary();
                p_current_dict.Add(p_node_key, p_current_node);
            }
            p_current_node = new NestedDictionaryNode();
        }