public IDictionary <string, IEnterspeedProperty> GetProperties(Item item) { if (item.IsDictionaryItem()) { IDictionary <string, IEnterspeedProperty> dictionaryProperties = _fieldConverter.ConvertFields(item, null, _fieldValueConverters.ToList()); return(dictionaryProperties); } EnterspeedSiteInfo siteOfItem = _enterspeedConfigurationService .GetConfiguration() .GetSite(item); if (siteOfItem == null) { return(null); } IDictionary <string, IEnterspeedProperty> properties = _fieldConverter.ConvertFields(item, siteOfItem, _fieldValueConverters.ToList()); properties.Add(MetaData, CreateMetaData(item)); IEnterspeedProperty renderings = CreateRenderings(item); if (renderings != null) { properties.Add(Renderings, renderings); } return(properties); }
private IEnterspeedProperty GetProperty(string name, JToken value) { var type = value.Type; if (type == JTokenType.String) { return(new StringEnterspeedProperty(name, value.Value <string>())); } if (type == JTokenType.Boolean) { return(new BooleanEnterspeedProperty(name, value.Value <bool>())); } if (type == JTokenType.Integer) { return(new NumberEnterspeedProperty(name, value.Value <int>())); } if (type == JTokenType.Array) { var arrayItems = new List <IEnterspeedProperty>(); foreach (var jToken in (JArray)value) { if (jToken is JObject item) { var properties = new Dictionary <string, IEnterspeedProperty>(); foreach (var prop in item) { IEnterspeedProperty property = null; if (name == "controls" && prop.Key == "value") { var gridControl = new GridControl(item); property = _enterspeedGridEditorService.ConvertGridEditor(gridControl); } if (property == null) { property = GetProperty(prop.Key, prop.Value); } if (property != null) { properties.Add(prop.Key, property); } } if (properties.Any()) { arrayItems.Add(new ObjectEnterspeedProperty(properties)); } } } return(new ArrayEnterspeedProperty(name, arrayItems.ToArray())); } if (type == JTokenType.Object) { if (value is JObject item) { var properties = new Dictionary <string, IEnterspeedProperty>(); foreach (var prop in item) { var property = GetProperty(prop.Key, prop.Value); if (property != null) { properties.Add(prop.Key, property); } } if (properties.Any()) { return(new ObjectEnterspeedProperty(name, properties)); } } } return(null); }