/* * Gets all the sub-categories (or topics?) of jt, and hangs them under node? */ //private static void decipherAreasJSON(JToken jt, Node node) private static void decipherAreasJSON(JToken jt, Category group) { if (jt is JProperty) { if (jt.ToObject<JProperty>().Name != IFIXIT_CATEGORY_OBJECT_KEY) { // Debug.WriteLine(" " + jt.ToObject<JProperty>().Name); // since it's not a device, it must be a group //Node curr = new Node(jt.ToObject<JProperty>().Name, new List<Node>()); Category curr = new Category(jt.ToObject<JProperty>().Name); //FIXME this is where we add to the 1:M, right? //group.Categories.Add(curr); group.AddCategory(curr); curr.Parent = group; curr.parentName = group.Name; if (jt.HasValues) { IJEnumerable<JToken> values = jt.Values(); foreach (JToken val in values) { decipherAreasJSON(val, curr); } } } // these are devices else { IJEnumerable<JToken> devs = jt.Values(); foreach (JToken dev in devs) { Topic d = new Topic(); d.Name = dev.ToString(); /* if (group.Devices == null) { group.Devices = new List<Topic>(); } */ //group.Topics.Add(d); group.AddTopic(d); d.Parent = group; d.parentName = group.Name; //node.getChildrenList().Add(new Node(dev.ToString(), null)); // Debug.WriteLine(" " + dev.ToString()); } } } else { // can currently safely ignore anything in this category // Debug.WriteLine("\n" + jt.ToString() + " not a property\n"); } }