public override object GetFormOptions(IServiceProvider services) { var options = new ModelFieldFormOptions { AddText = AddText, IsListValue = IsListValue, ItemTypes = new List <ContentItemType>() }; foreach (var contentMetadata in ValueContentMetadata.GetDerivedMetadataWithHierarhy(true)) { if (contentMetadata.ModelType.IsAbstract) { continue; } options.ItemTypes.Add(new ContentItemType { Name = contentMetadata.Name, Title = contentMetadata.Title }); } return(options); }
public override object ConvetValueToData(object value) { if (IsListValue) { var list = (IList)value; var result = new List <IDictionary <string, object> >(); foreach (var item in list) { result.Add(ValueContentMetadata.ConvertContentModelToDictionary(item)); } return(result); } else { return(ValueContentMetadata.ConvertContentModelToDictionary(value)); } }
public override object ConvetValueFromData(object value) { if (IsListValue) { var dataList = (IEnumerable <IDictionary <string, object> >)value; var result = CreateListValue(); foreach (var itemData in dataList) { var item = ValueContentMetadata.ConvertDictionaryToContentModel(itemData); result.Add(item); } return(result); } else { return(ValueContentMetadata.ConvertDictionaryToContentModel((IDictionary <string, object>)value)); } }