private Dictionary <string, object> ExtractProperties(CustomTypedEntity <Content> typedEntity) { var dictionary = new Dictionary <string, object>(); foreach (TypedAttribute attribute in typedEntity.Attributes) { string key = attribute.AttributeDefinition.Alias; if (key.Contains("system")) { continue; } LocalizedString type = attribute.AttributeDefinition.AttributeType.Name; dynamic value = SetPropertyValue(typedEntity, key, attribute, type); dictionary.Add(key, value); } return(dictionary); }
private dynamic SetPropertyValue(CustomTypedEntity <Content> typedEntity, string key, TypedAttribute attribute, LocalizedString type) { dynamic value = attribute.DynamicValue; if (type == UploaderType) { value = _url.GetMediaUrl(typedEntity, key); } else if (type == MediaPickerType) { string id = string.Concat(string.Empty, value); if (!string.IsNullOrEmpty(id)) { value = _url.GetMediaUrl(id, "uploadedFile"); } } return(value); }
internal object Flatten(string itemUrl, CustomTypedEntity <Content> typedEntity) { Dictionary <string, object> properties = ExtractProperties(typedEntity); IEnumerable <HiveId> children = typedEntity.AllChildIds(); List <string> childrenUrls = children .Select(child => _hiveManager.Cms().Content.GetById(child)) .Select(entity => entity.NiceUrl()) .ToList(); return(new { id = itemUrl, UtcCreated = ConvertDateTime(typedEntity.UtcCreated), UtcModified = ConvertDateTime(typedEntity.UtcModified), UtcStatusChanged = ConvertDateTime(typedEntity.UtcStatusChanged), properties, children = childrenUrls }); }