private void RebuildStructure() { m_objectByNames.Clear(); List <PropertyDescriptor> properties = new List <PropertyDescriptor>(); if (m_currentSchema != null) { foreach (KeyValuePair <string, JToken> pair in m_currentSchema) { if (pair.Value is JValue) { properties.Add(new SchemaPropertyDescriptor(this, pair.Key, (JValue)pair.Value)); } else if (pair.Value is JObject) { JObject jContainer = (JObject)pair.Value; switch (pair.Key) { case "objects": foreach (KeyValuePair <string, JToken> innerPair in jContainer) { if (innerPair.Value is JObject) { string objectName = innerPair.Key; JObject innerObject = (JObject)innerPair.Value; ObjectAdapter objectAdapter = new ObjectAdapter(this, innerPair.Key, innerObject); m_objectByNames.Add(objectName, objectAdapter); properties.Add( new AdapterPropertyDescriptor <ObjectAdapter>( objectAdapter, objectName, new Attribute[] { new CategoryAttribute((string)innerObject["group"]), new DescriptionAttribute((string)innerObject["description"]) } ) ); } } break; } } } } PropertyDescriptor[] props = (PropertyDescriptor[])properties.ToArray <PropertyDescriptor>(); m_properties = new PropertyDescriptorCollection(props); }
internal ActionsListAdapter(ObjectAdapter adapter, JObject jObject) { List <PropertyDescriptor> properties = new List <PropertyDescriptor>(); foreach (KeyValuePair <string, JToken> pair in jObject) { if (pair.Value is JObject) { properties.Add(new ActionPropertyDescriptor(adapter, pair.Key, (JObject)pair.Value)); } } PropertyDescriptor[] props = (PropertyDescriptor[])properties.ToArray <PropertyDescriptor>(); m_properties = new PropertyDescriptorCollection(props); m_propertyOwner = adapter; }
internal PropertiesListAdapter(ObjectAdapter adapter, JObject jObject, Dictionary <string, PropertyPropertyDescriptor> propertiesByName) { List <PropertyDescriptor> properties = new List <PropertyDescriptor>(); foreach (KeyValuePair <string, JToken> pair in jObject) { if (pair.Value is JObject) { string propertyName = pair.Key; PropertyPropertyDescriptor descriptor = new PropertyPropertyDescriptor(adapter, propertyName, (JObject)pair.Value); propertiesByName.Add(propertyName, descriptor); properties.Add(descriptor); } } PropertyDescriptor[] props = (PropertyDescriptor[])properties.ToArray <PropertyDescriptor>(); m_properties = new PropertyDescriptorCollection(props); m_propertyOwner = adapter; }
internal PropertyPropertyDescriptor(ObjectAdapter adapter, string name, JObject jObject) : base(name, null) { m_objectAdapter = adapter; m_name = name; m_value = null; string typeName = (string)jObject["type"]; m_type = DataTypes.NameToType(typeName); m_isReadonly = (bool)jObject["readonly"]; m_showGraph = (bool?)jObject["show_graph"] ?? false; string description = (string)jObject["description"]; if (m_showGraph) { description += "\n(showGraph)"; } JObject limits = (JObject)jObject["limits"]; if (limits != null) { m_limitsMin = Convert.ChangeType(((JValue)limits["min"]).Value, m_type); m_limitsMax = Convert.ChangeType(((JValue)limits["max"]).Value, m_type); description += String.Format("\nValue limits: min = {0}; max = {1}", m_limitsMin, m_limitsMax); } else { m_limitsMin = null; m_limitsMax = null; } this.AttributeArray = new Attribute[] { new CategoryAttribute("Properties"), new DescriptionAttribute(description), //new ReadOnlyAttribute(m_isReadonly), }; }