Beispiel #1
0
        public static DataNode FromDictionary(IDictionary <string, object> dictionary)
        {
            DataNode dataNode = new DataNode("rval");

            foreach (KeyValuePair <string, object> current in dictionary)
            {
                dataNode.AddNode(DataNodeDictionary.FromObject(current.Key, current.Value));
            }
            return(dataNode);
        }
        private static DataNode ReadSubNodes(BinaryReader br, bool isList, List <string> header)
        {
            DataNode dataNode = new DataNode(DataNodeBinary.ReadString(br, header));

            dataNode.IsList = isList;
            int num = br.ReadInt32();

            for (int i = 0; i < num; i++)
            {
                DataNode node = DataNodeBinary.ReadFromBinary(br, header);
                dataNode.AddNode(node);
            }
            return(dataNode);
        }
Beispiel #3
0
        private static DataNode FromObject(string name, object obj)
        {
            IList list = obj as IList;

            if (list != null)
            {
                DataNode dataNode = new DataNode(name, true);
                foreach (object current in list)
                {
                    dataNode.AddNode(DataNodeDictionary.FromObject(null, current));
                }
                return(dataNode);
            }
            Dictionary <string, object> dictionary = obj as Dictionary <string, object>;

            if (dictionary != null)
            {
                DataNode dataNode2 = new DataNode(name, false);
                foreach (KeyValuePair <string, object> current2 in dictionary)
                {
                    dataNode2.AddNode(DataNodeDictionary.FromObject(current2.Key, current2.Value));
                }
                return(dataNode2);
            }
            DataNode dataNode3 = new DataNode(name, false);

            if (obj != null)
            {
                dataNode3.Content = obj.ToString();
            }
            else
            {
                dataNode3.Content = string.Empty;
            }
            return(dataNode3);
        }