示例#1
0
            public PROFILE_FOR_XML_TREENODE(string node_name, JArray arr)
            {
                name      = node_name;
                children  = new PROFILE_FOR_XML_TREENODE[arr.Count];
                value_str = "This is an array, stupid!";
                if (arr.Count > 0)
                {
                    hasChildren = true;
                }
                int currentChildIndex = 0;

                foreach (JObject node in arr.Children())
                {
                    if (node["Comment"] != null)
                    {
                        //Console.WriteLine("Comment: " + node["Comment"].ToString());
                        children[currentChildIndex]           = new PROFILE_FOR_XML_TREENODE();
                        children[currentChildIndex].isComment = true;
                        children[currentChildIndex].isValid   = true;
                        children[currentChildIndex].value_str = node["Comment"].ToString();
                        isValid = true;
                    }
                    else
                    {
                        if (node["Name"] != null && node["Value"] != null)
                        {
                            if (node["Value"].Type == JTokenType.Array)
                            {
                                children[currentChildIndex] = new PROFILE_FOR_XML_TREENODE(node["Name"].ToString(), (JArray)node["Value"]);
                            }
                            else
                            {
                                children[currentChildIndex]           = new PROFILE_FOR_XML_TREENODE();
                                children[currentChildIndex].name      = node["Name"].ToString();
                                children[currentChildIndex].value_str = node["Value"].ToString();
                            }

                            if (node["RepeatForAllEntries"] != null)
                            {
                                if (node["RepeatForAllEntries"].Type == JTokenType.Boolean)
                                {
                                    children[currentChildIndex].repeatForAllEntries = (bool)node["RepeatForAllEntries"];
                                }
                                else
                                {
                                    children[currentChildIndex].repeatForAllEntries = bool.Parse(node["RepeatForAllEntries"].ToString());
                                }
                                //Console.WriteLine("RepeatForAllEntries set to " + children[currentChildIndex].repeatForAllEntries + " for node: " + children[currentChildIndex].Name);
                            }

                            isValid = true;
                        }
                    }
                    currentChildIndex++;
                }
            }
示例#2
0
            public PROFILE_FOR_XML(string json)
            {
                JObject o = JObject.Parse(json);

                if (o["PROFILE_NAME"] != null)
                {
                    profile_name = o["PROFILE_NAME"].ToString();
                    if (o["FORMAT"] != null && o["XML_TREE"] != null)
                    {
                        foreach (JProperty obj in o["FORMAT"].Children())
                        {
                            formats.Add(obj.Name, new PROFILE_FOR_XML_FORMAT(obj));
                        }
                        xml_root = new PROFILE_FOR_XML_TREENODE("", (JArray)o["XML_TREE"]);
                        isValid  = true;
                    }
                }
            }