示例#1
0
        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);
        }
示例#2
0
 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));
     }
 }
示例#3
0
 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));
     }
 }