private static BindPropertyInfo HandleDetailClassTypeProperty(PropertyInfo propertyInfo) { var detailInfo = new BindPropertyInfo { HasVariants = true, VariantsType = propertyInfo.PropertyType, SelectedValue = propertyInfo.Name, Name = propertyInfo.Name }; // get link var showLinkedAttribute = propertyInfo.GetCustomAttributes(false) .FirstOrDefault(item => item is ShowLinkedAttribute) as ShowLinkedAttribute; if (showLinkedAttribute != null && !string.IsNullOrEmpty(showLinkedAttribute.PropertyName)) { // check does property exists var linkedProperty = propertyInfo.PropertyType.GetProperty(showLinkedAttribute.PropertyName); if (linkedProperty != null) { detailInfo.DisplayMemberPath = linkedProperty.Name; detailInfo.DataType = linkedProperty.PropertyType; } } // get binding settings var bindSelectionAttribute = propertyInfo.GetCustomAttributes(false) .FirstOrDefault(item => item is BindSelectionAttribute) as BindSelectionAttribute; if (bindSelectionAttribute != null && !string.IsNullOrEmpty(bindSelectionAttribute.SourcePath)) { detailInfo.SelectedValuePath = bindSelectionAttribute.SourcePath; } return(detailInfo); }
public static IEnumerable <BindPropertyInfo> GenerateDetailsInfo <T>() { var detailsInfo = new List <BindPropertyInfo>(); foreach (var propertyInfo in typeof(T).GetProperties()) { // check should be shown this property if (!ShowProperty(propertyInfo) || !ShowInDetailsProperty(propertyInfo)) { continue; } // create column info object BindPropertyInfo detailInfo = null; Type propertyType = Nullable.GetUnderlyingType(propertyInfo.PropertyType) ?? propertyInfo.PropertyType; if (propertyInfo.PropertyType.IsClass && propertyInfo.PropertyType != typeof(string)) { detailInfo = HandleDetailClassTypeProperty(propertyInfo); } else if (propertyType.IsEnum) { detailInfo = new BindPropertyInfo { HasVariants = true, VariantsType = propertyInfo.PropertyType, DisplayMemberPath = "Description", SelectedValuePath = "Value", SelectedValue = propertyInfo.Name, Name = propertyInfo.Name, DataType = propertyInfo.PropertyType, Variants = EnumHelper.ToListOfOriginalValueAndDescription(propertyType) } } ; else { detailInfo = new BindPropertyInfo { Name = propertyInfo.Name, DataType = propertyInfo.PropertyType } }; // check IsReadOnly detailInfo.IsReadOnly = IsReadOnlyProperty(propertyInfo); // check IsReadOnly on editing item detailInfo.IsReadOnlyOnEditing = IsReadOnlyOnEditingProperty(propertyInfo); // check HideOnEditingInDetails detailInfo.HideOnEditing = HideOnEditingInDetailsProperty(propertyInfo); // check IsRequired detailInfo.IsRequired = IsRequiredProperty(propertyInfo); // get validation rules detailInfo.ValidationRules = GetValidationRules(propertyInfo); // set format detailInfo.Format = GetPropertyFormat(propertyInfo); // set header detailInfo.Header = GetPropertyHeader(propertyInfo); // set order detailInfo.Order = GetPropertyOrder(propertyInfo); // add to all columns detailsInfo.Add(detailInfo); } return(detailsInfo.OrderBy(item => item.Order)); }
public static DatePicker InsertDatePicker(Grid grid, int row, BindPropertyInfo bindPropertyInfo) { return(InsertDatePicker(grid, row, bindPropertyInfo.Header, bindPropertyInfo.IsReadOnly, bindPropertyInfo.ValidationRules, bindPropertyInfo.Name)); }
public static DatePicker DatePicker(Grid grid, BindPropertyInfo bindPropertyInfo) { return(DatePicker(grid, bindPropertyInfo.Header, bindPropertyInfo.IsReadOnly, bindPropertyInfo.ValidationRules, bindPropertyInfo.Name)); }
public static ComboBox InsertComboBox(Grid grid, int row, BindPropertyInfo bindPropertyInfo) { return(InsertComboBox(grid, row, bindPropertyInfo.Header, bindPropertyInfo.IsReadOnly, bindPropertyInfo.ValidationRules, bindPropertyInfo.SelectedValuePath, bindPropertyInfo.DisplayMemberPath, bindPropertyInfo.SelectedValue, bindPropertyInfo.Variants)); }
public static CheckBox CheckBox(Grid grid, BindPropertyInfo bindPropertyInfo) { return(CheckBox(grid, bindPropertyInfo.Header, bindPropertyInfo.IsReadOnly, bindPropertyInfo.Name)); }
public static TextBox TextBox(Grid grid, BindPropertyInfo bindPropertyInfo) { return(TextBox(grid, bindPropertyInfo.Header, bindPropertyInfo.IsReadOnly, bindPropertyInfo.ValidationRules, bindPropertyInfo.Name)); }
public static TextBox NumericBox(Grid grid, BindPropertyInfo bindPropertyInfo, MaskType maskType) { return(NumericBox(grid, bindPropertyInfo.Header, bindPropertyInfo.IsReadOnly, bindPropertyInfo.ValidationRules, maskType, bindPropertyInfo.Name)); }