示例#1
0
        private void AddModules(JObject data)
        {
            if (data["modules"].Count() > 0)
            {
                Dictionary<string, JArray> modules = data["modules"].ToObject<Dictionary<string, JArray>>();

                foreach (var key in modules.Keys)
                {
                    foreach(var module in modules[key])
                    {
                        Module m = new Module();
                        m.ID = Convert.ToInt64(module);
                        m.Type = key;
                        Modules.Add(m);
                    }
                    //Console.WriteLine(key + " " + modules[key]);
                }
                /*
                foreach (var n in data["modules_tree"])
                {
                    Module m = new Module();
                    m.ID = Convert.ToInt64(n.First()["module_id"].ToString());
                    m.Type = n.First()["type"].ToString();
                    Modules.Add(m);
                }
                */
            }
        }
示例#2
0
        private List<Module> GetModules(String json)
        {
            List<Module> results = new List<Module>();
            JObject parsedJson = JObject.Parse(json);
            Dictionary<string, JObject> modules = parsedJson["data"].ToObject<Dictionary<string, JObject>>();

            foreach(JToken m in parsedJson["data"].Values())
            {
                Module module = new Module(m);
                results.Add(module);
            }

            return results;
        }