public static object GetDropDownValue(InputTypeAttribute inputAttribute, PropertyInfo p, ContentProperty propertyPost) { if (inputAttribute == null || propertyPost == null) { return(null); } if (!inputAttribute.MultiSelect) { return(propertyPost.Value.MyTryConvert(p.PropertyType)); } else { return(propertyPost.MultiValue.MyTryConvert(p.PropertyType)); } }
public static ContentProperty GetContentPropertyByPropertyInfo(this PropertyInfo p, object input) { var result = new ContentProperty(); if (p.GetObjectCustomAttribute <BasePropertyAttribute>() != null) { result.BaseProperty = true; } if (p.GetObjectCustomAttribute <IgnoreEditAttribute>() != null) { result.IgnoreProperty = true; } if (p.GetObjectCustomAttribute <CustomPropertyAttribute>() != null) { result.CustomProperty = true; } result.Key = p.Name; var cValue = input.MyTryConvert(typeof(string)); if (cValue != null) { result.Value = (string)cValue; } Type relatedType = null; var inputAttribute = p.GetCustomAttribute <InputTypeAttribute>(); if (inputAttribute != null) { result.EditorType = inputAttribute.EditorType; result.MultiSelect = inputAttribute.MultiSelect; relatedType = inputAttribute.RelatedType; result.RangeMax = inputAttribute.RangeMax; result.RangeMin = inputAttribute.RangeMin; if (inputAttribute.RangeMaxSelf) { var max = input.MyTryConvert <int>(); result.RangeMax = max; } } var propertyType = p.GetType(); var displayAttribute = p.GetCustomAttribute <DisplayAttribute>(); if (displayAttribute != null && !String.IsNullOrEmpty(displayAttribute.Name)) { result.Title = displayAttribute.Name; } else { result.Title = p.Name.SpacesFromCamel(); } var type = p.PropertyType; var datetimeType = typeof(DateTime); if (result.EditorType == EnumInputType.DropDwon) { if (result.MultiSelect) { result.MultiValue = input.MyTryConvert <List <string> >(); result.Value = ""; } p.SetDropDownSelect( (List <DropDownViewModel>)result.SelectItems, relatedType, result.Value, result.MultiValue); } return(result); //return new ContentProperty() //{ // Key = p.Name, // Value = postValue, // EditorType = editorType, // ValueType = propertyType.FullName, // Title = displayTitle, // MultiSelect = multiSelect, // SelectItems = editorType == EnumInputType.DropDwon ? selector : Enumerable.Empty<DropDownViewModel>(), // MultiValue = multiSelect ? postMultiValue : Enumerable.Empty<string>(), //}; }
public ContentPropertyIndex(ContentProperty property, int index) { Property = property; Index = index; }