private void SetEditLink(IPropertySource source, PropertyItem item) { var attr = source.GetAttribute <EditLinkAttribute>(); if (attr == null) { return; } if (attr.Value) { item.EditLink = true; } if (attr.ItemType != null) { item.EditLinkItemType = attr.ItemType; } if (attr.IdField != null) { item.EditLinkIdField = attr.IdField; } if (attr.CssClass != null) { item.EditLinkCssClass = attr.CssClass; } if (item.EditLinkItemType != null && item.EditLinkIdField == null) { item.EditLinkIdField = AutoDetermineIdField(source.BasedOnField); } }
private void SetTitle(IPropertySource source, PropertyItem item) { if (source.Property != null) { var attr = source.Property.GetCustomAttribute <DisplayNameAttribute>(false); if (attr != null) { item.Title = attr.DisplayName; } } if (item.Title == null) { var basedOnField = source.BasedOnField; if (basedOnField is object) { item.Title = basedOnField.Caption is object? basedOnField.Caption.Key : basedOnField.AutoTextKey; } else { item.Title = item.Name; } } }
private void SetWidth(IPropertySource source, PropertyItem item) { var widthAttr = source.GetAttribute <WidthAttribute>(); var basedOnField = source.BasedOnField; item.Width = widthAttr == null || widthAttr.Value == 0 ? (!ReferenceEquals(null, basedOnField) ? AutoWidth(basedOnField) : 80) : widthAttr.Value; if (widthAttr != null && widthAttr.Value != 0) { item.WidthSet = true; } if (widthAttr != null && (widthAttr.Min != 0)) { item.MinWidth = widthAttr.Min; } if (widthAttr != null && (widthAttr.Max != 0)) { item.MaxWidth = widthAttr.Max; } var labelWidthAttr = source.GetAttribute <LabelWidthAttribute>() ?? labelWidthPrior; if (labelWidthAttr != null) { item.LabelWidth = labelWidthAttr.Value; if (!labelWidthAttr.JustThis) { labelWidthPrior = labelWidthAttr.UntilNext ? labelWidthAttr : null; } } }
private void SetSorting(IPropertySource source, PropertyItem item) { var sortOrderAttr = source.GetAttribute <SortOrderAttribute>(); if (sortOrderAttr != null && sortOrderAttr.SortOrder != 0) { item.SortOrder = sortOrderAttr.SortOrder; } var sortableAttr = source.GetAttribute <SortableAttribute>(); if (sortableAttr != null) { if (!sortableAttr.Value) { item.Sortable = false; } return; } if (source.BasedOnField is object && source.BasedOnField.Flags.HasFlag(FieldFlags.NotMapped)) { item.Sortable = false; } }
public override void Process(IPropertySource source, PropertyItem item) { SetAlignment(source, item); SetCategory(source, item); SetCssClass(source, item); SetDefaultValue(source, item); SetEditLink(source, item); SetEditing(source, item); SetFiltering(source, item); SetFormatting(source, item); SetHideOnInsert(source, item); SetHideOnUpdate(source, item); SetHint(source, item); SetInsertable(source, item); SetOneWay(source, item); SetPlaceholder(source, item); SetReadOnly(source, item); SetRequired(source, item); SetResizable(source, item); SetSorting(source, item); SetTitle(source, item); SetUpdatable(source, item); SetVisible(source, item); SetWidth(source, item); }
private void SetTitle(IPropertySource source, PropertyItem item) { if (source.Property != null) { var attr = source.Property.GetCustomAttribute<DisplayNameAttribute>(false); if (attr != null) item.Title = attr.DisplayName; } if (item.Title == null) { var basedOnField = source.BasedOnField; if (!ReferenceEquals(null, basedOnField)) { Field textualField = null; if (basedOnField.TextualField != null) textualField = basedOnField.Fields.FindFieldByPropertyName(basedOnField.TextualField) ?? basedOnField.Fields.FindField(basedOnField.TextualField); if (!ReferenceEquals(null, textualField)) { item.Title = !object.ReferenceEquals(null, textualField.Caption) ? textualField.Caption.Key : textualField.Title; } else { item.Title = !object.ReferenceEquals(null, basedOnField.Caption) ? basedOnField.Caption.Key : basedOnField.Title; } } else item.Title = item.Name; } }
public override void Process(IPropertySource source, PropertyItem item) { SetAlignment(source, item); SetCategory(source, item); SetCollapsible(source, item); SetTab(source, item); SetCssClass(source, item); SetDefaultValue(source, item); SetEditLink(source, item); SetEditing(source, item); SetFiltering(source, item); SetFormatting(source, item); SetHideOnInsert(source, item); SetHideOnUpdate(source, item); SetHint(source, item); SetInsertable(source, item); SetInsertPermission(source, item); SetOneWay(source, item); SetPlaceholder(source, item); SetReadOnly(source, item); SetReadPermission(source, item); SetRequired(source, item); SetResizable(source, item); SetSorting(source, item); SetTitle(source, item); SetUpdatable(source, item); SetUpdatePermission(source, item); SetVisible(source, item); SetWidth(source, item); }
private void SetInsertPermission(IPropertySource source, PropertyItem item) { if (source.Property != null) { var attr = source.Property.GetAttribute <InsertPermissionAttribute>(false); if (attr != null) { if (attr.Permission != "*") { item.InsertPermission = attr.Permission ?? "?"; } return; } } if (source.BasedOnField is object) { if (source.BasedOnField.InsertPermission != null && source.BasedOnField.InsertPermission != "*") { item.InsertPermission = source.BasedOnField.InsertPermission; } } }
private void SetUpdatePermission(IPropertySource source, PropertyItem item) { if (source.Property != null) { var attr = source.Property.GetAttribute <UpdatePermissionAttribute>(false); if (attr != null) { if (attr.Permission != "*") { item.UpdatePermission = attr.Permission ?? "?"; } return; } } if (!ReferenceEquals(null, source.BasedOnField)) { if (source.BasedOnField.UpdatePermission != null && source.BasedOnField.UpdatePermission != "*") { item.UpdatePermission = source.BasedOnField.UpdatePermission; } } }
private void SetTitle(IPropertySource source, PropertyItem item) { if (source.Property != null) { var attr = source.Property.GetCustomAttribute <DisplayNameAttribute>(false); if (attr != null) { item.Title = attr.DisplayName; } } if (item.Title == null) { var basedOnField = source.BasedOnField; if (!ReferenceEquals(null, basedOnField)) { item.Title = !object.ReferenceEquals(null, basedOnField.Caption) ? basedOnField.Caption.Key : basedOnField.Title; } else { item.Title = item.Name; } } }
private void SetCategory(IPropertySource source, PropertyItem item) { var attr = source.GetAttribute<CategoryAttribute>(); if (attr != null) item.Category = attr.Category; else if (Items != null && Items.Count > 0) item.Category = Items[Items.Count - 1].Category; }
private void SetEditing(IPropertySource source, PropertyItem item) { var editorTypeAttr = source.GetAttribute<EditorTypeAttribute>(); if (editorTypeAttr == null) { item.EditorType = AutoDetermineEditorType(source.ValueType, source.EnumType, item.EditorParams); } else { item.EditorType = editorTypeAttr.EditorType; editorTypeAttr.SetParams(item.EditorParams); } if (source.EnumType != null) item.EditorParams["enumKey"] = EnumMapper.GetEnumTypeKey(source.EnumType); if (!ReferenceEquals(null, source.BasedOnField)) { if (item.EditorType == "Decimal" && (source.BasedOnField is DoubleField || source.BasedOnField is DecimalField) && source.BasedOnField.Size > 0 && source.BasedOnField.Scale < source.BasedOnField.Size && !item.EditorParams.ContainsKey("minValue") && !item.EditorParams.ContainsKey("maxValue")) { string minVal = new String('0', source.BasedOnField.Size - source.BasedOnField.Scale); if (source.BasedOnField.Scale > 0) minVal += "." + new String('0', source.BasedOnField.Scale); string maxVal = minVal.Replace('0', '9'); item.EditorParams["minValue"] = minVal; item.EditorParams["maxValue"] = maxVal; } else if (source.BasedOnField.Size > 0) { item.EditorParams["maxLength"] = source.BasedOnField.Size; item.MaxLength = source.BasedOnField.Size; } } var maxLengthAttr = source.GetAttribute<MaxLengthAttribute>(); if (maxLengthAttr != null) { item.MaxLength = maxLengthAttr.MaxLength; item.EditorParams["maxLength"] = maxLengthAttr.MaxLength; } foreach (EditorOptionAttribute param in source.GetAttributes<EditorOptionAttribute>()) { var key = param.Key; if (key != null && key.Length >= 1) key = key.Substring(0, 1).ToLowerInvariant() + key.Substring(1); item.EditorParams[key] = param.Value; } }
private void SetOneWay(IPropertySource source, PropertyItem item) { var attr = source.GetAttribute <OneWayAttribute>(); if (attr != null) { item.OneWay = true; } }
private void SetSortOrder(IPropertySource source, PropertyItem item) { var attr = source.GetAttribute <SortOrderAttribute>(); if (attr != null && attr.SortOrder != 0) { item.SortOrder = attr.SortOrder; } }
private void SetVisible(IPropertySource source, PropertyItem item) { var attr = source.GetAttribute <VisibleAttribute>(); if (attr != null && attr.Value == false) { item.Visible = false; } }
public PropertyValue(IPropertySource propertySource, string propertyName) { if (propertySource == null) { throw new ArgumentNullException(nameof(propertySource)); } PropertyName = DePascal(propertyName); Value = propertySource.GetProperty(propertyName); }
private int GetRouting(IPropertySource actorConfig) { if (actorConfig.ContainsProperty("Routing")) { return(int.Parse(actorConfig["Routing"])); } return(0); }
private void SetHint(IPropertySource source, PropertyItem item) { var attr = source.GetAttribute <HintAttribute>(); if (attr != null) { item.Hint = attr.Hint; } }
private void SetGrouping(IPropertySource source, PropertyItem item) { var groupOrderAttr = source.GetAttribute <GroupOrderAttribute>(); if (groupOrderAttr != null && groupOrderAttr.GroupOrder != 0) { item.GroupOrder = groupOrderAttr.GroupOrder; } }
private void SetPlaceholder(IPropertySource source, PropertyItem item) { var attr = source.GetAttribute <PlaceholderAttribute>(); if (attr != null) { item.Placeholder = attr.Value; } }
private void SetHideOnInsert(IPropertySource source, PropertyItem item) { var attr = source.GetAttribute <HideOnInsertAttribute>(); if (attr != null && attr.Value) { item.HideOnInsert = true; } }
private void SetReadOnly(IPropertySource source, PropertyItem item) { var attr = source.GetAttribute <ReadOnlyAttribute>(); if (attr != null && attr.IsReadOnly) { item.ReadOnly = true; } }
private void SetCssClass(IPropertySource source, PropertyItem item) { var attr = source.GetAttribute <CssClassAttribute>(); if (attr != null) { item.CssClass = attr.CssClass; } }
private void SetAllowHide(IPropertySource source, PropertyItem item) { var attr = source.GetAttribute <AllowHideAttribute>(); if (attr != null && attr.Value == false) { item.AllowHide = false; } }
private void SetAlignment(IPropertySource source, PropertyItem item) { var attr = source.GetAttribute <AlignmentAttribute>(); if (attr != null) { item.Alignment = attr.Value; } }
private void SetFormCssClass(IPropertySource source, PropertyItem item) { var attr = source.GetAttribute <FormCssClassAttribute>(); if (attr != null) { item.FormCssClass = attr.Value; } }
private void SetSorting(IPropertySource source, PropertyItem item) { var sortOrderAttr = source.GetAttribute<SortOrderAttribute>(); if (sortOrderAttr != null && sortOrderAttr.SortOrder != 0) item.SortOrder = sortOrderAttr.SortOrder; var sortableAttr = source.GetAttribute<SortableAttribute>(); if (sortableAttr != null && !sortableAttr.Value) item.Sortable = false; }
private void SetCssClass(IPropertySource source, PropertyItem item) { var attr = source.GetAttribute<CssClassAttribute>(); if (attr != null) item.CssClass = attr.CssClass; var hattr = source.GetAttribute<HeaderCssClassAttribute>(); if (hattr != null) item.HeaderCssClass = hattr.Value; }
private void SetFormCssClass(IPropertySource source, PropertyItem item) { var attr = source.GetAttribute <FormCssClassAttribute>() ?? formCssClassPrior; if (attr != null) { item.FormCssClass = attr.Value; formCssClassPrior = attr.UntilNext ? attr : null; } }
private void SetCollapsible(IPropertySource source, PropertyItem item) { var attr = source.GetAttribute<CollapsibleAttribute>(); if (attr != null && attr.Value) { item.Collapsible = true; if (attr.Collapsed) item.Collapsed = true; } }
private void SetCategory(IPropertySource source, PropertyItem item) { var attr = source.GetAttribute <CategoryAttribute>(); if (attr != null) { item.Category = attr.Category; } else if (Items != null && Items.Count > 0) { item.Category = Items[^ 1].Category;
private void SetWidth(IPropertySource source, PropertyItem item) { var widthAttr = source.GetAttribute<WidthAttribute>(); var basedOnField = source.BasedOnField; item.Width = widthAttr == null ? (!ReferenceEquals(null, basedOnField) ? AutoWidth(basedOnField) : 80) : widthAttr.Value; if (widthAttr != null && (widthAttr.Min != 0)) item.MinWidth = widthAttr.Min; if (widthAttr != null && (widthAttr.Max != 0)) item.MaxWidth = widthAttr.Max; }
private void SetTab(IPropertySource source, PropertyItem item) { var attr = source.GetAttribute <TabAttribute>(); if (attr != null) { item.Tab = attr.Value; } else if (Items != null && Items.Count > 0) { item.Tab = Items[^ 1].Tab;
private void SetCollapsible(IPropertySource source, PropertyItem item) { var attr = source.GetAttribute <CollapsibleAttribute>(); if (attr != null && attr.Value) { item.Collapsible = true; if (attr.Collapsed) { item.Collapsed = true; } } }
public static List <PropertyValue> CreatePropertyValues(IPropertySource propertySource, params string[] propertyNames) { if (propertySource == null) { throw new ArgumentNullException(nameof(propertySource)); } List <PropertyValue> r = new List <PropertyValue>(propertyNames.Length); foreach (string n in propertyNames) { r.Add(new PropertyValue(propertySource, n)); } return(r); }
private void SetRequired(IPropertySource source, PropertyItem item) { var attr = source.GetAttribute<RequiredAttribute>(); if (attr != null) { if (attr.IsRequired) item.Required = true; } else if (!ReferenceEquals(null, source.BasedOnField) && (source.BasedOnField.Flags & FieldFlags.NotNull) == FieldFlags.NotNull) { item.Required = true; } }
private void SetWidth(IPropertySource source, PropertyItem item) { var widthAttr = source.GetAttribute<WidthAttribute>(); var basedOnField = source.BasedOnField; item.Width = widthAttr == null ? (!ReferenceEquals(null, basedOnField) ? AutoWidth(basedOnField) : 80) : widthAttr.Value; if (widthAttr != null && (widthAttr.Min != 0)) item.MinWidth = widthAttr.Min; if (widthAttr != null && (widthAttr.Max != 0)) item.MaxWidth = widthAttr.Max; var labelWidthAttr = source.GetAttribute<LabelWidthAttribute>(); if (labelWidthAttr != null) item.LabelWidth = labelWidthAttr.Value; }
private void SetDefaultValue(IPropertySource source, PropertyItem item) { if (source.Property != null) { var attr = source.Property.GetAttribute<DefaultValueAttribute>(false); if (attr != null) { item.DefaultValue = attr.Value; return; } } if (!ReferenceEquals(null, source.BasedOnField) && source.BasedOnField.DefaultValue != null) item.DefaultValue = source.BasedOnField.DefaultValue; }
private void SetSorting(IPropertySource source, PropertyItem item) { var sortOrderAttr = source.GetAttribute <SortOrderAttribute>(); if (sortOrderAttr != null && sortOrderAttr.SortOrder != 0) { item.SortOrder = sortOrderAttr.SortOrder; } var sortableAttr = source.GetAttribute <SortableAttribute>(); if (sortableAttr != null && !sortableAttr.Value) { item.Sortable = false; } }
public override void Process(IPropertySource source, PropertyItem item) { var attr = source.GetAttribute<LocalizableAttribute>(); if (attr != null) { item.Localizable = true; return; } if (!ReferenceEquals(null, source.BasedOnField) && localizationRowHandler != null && localizationRowHandler.IsLocalized(source.BasedOnField)) { item.Localizable = true; } }
private void SetDefaultValue(IPropertySource source, PropertyItem item) { if (source.Property != null) { var attr = source.Property.GetAttribute <DefaultValueAttribute>(false); if (attr != null) { item.DefaultValue = attr.Value; return; } } if (source.BasedOnField is object && source.BasedOnField.DefaultValue != null) { item.DefaultValue = source.BasedOnField.DefaultValue; } }
private void SetSorting(IPropertySource source, PropertyItem item) { var sortOrderAttr = source.GetAttribute<SortOrderAttribute>(); if (sortOrderAttr != null && sortOrderAttr.SortOrder != 0) item.SortOrder = sortOrderAttr.SortOrder; var sortableAttr = source.GetAttribute<SortableAttribute>(); if (sortableAttr != null) { if (!sortableAttr.Value) item.Sortable = false; return; } if (!ReferenceEquals(null, source.BasedOnField) && source.BasedOnField.Flags.HasFlag(FieldFlags.NotMapped)) item.Sortable = false; }
private void SetUpdatable(IPropertySource source, PropertyItem item) { if (source.Property != null) { var attr = source.Property.GetAttribute<UpdatableAttribute>(false); if (attr != null) { if (!attr.Value) item.Updatable = false; return; } } if (!ReferenceEquals(null, source.BasedOnField)) { if ((source.BasedOnField.Flags & FieldFlags.Updatable) != FieldFlags.Updatable) item.Updatable = false; } }
private void SetUpdatePermission(IPropertySource source, PropertyItem item) { if (source.Property != null) { var attr = source.Property.GetAttribute<UpdatePermissionAttribute>(false); if (attr != null) { if (attr.Permission != "*") item.UpdatePermission = attr.Permission ?? "?"; return; } } if (!ReferenceEquals(null, source.BasedOnField)) { if (source.BasedOnField.UpdatePermission != null && source.BasedOnField.UpdatePermission != "*") item.UpdatePermission = source.BasedOnField.UpdatePermission; } }
private void SetEditLink(IPropertySource source, PropertyItem item) { var attr = source.GetAttribute<EditLinkAttribute>(); if (attr == null) return; if (attr.Value) item.EditLink = true; if (attr.ItemType != null) item.EditLinkItemType = attr.ItemType; if (attr.IdField != null) item.EditLinkIdField = attr.IdField; if (attr.CssClass != null) item.EditLinkCssClass = attr.CssClass; if (item.EditLinkItemType != null && item.EditLinkIdField == null) { item.EditLinkIdField = AutoDetermineIdField(source.BasedOnField); } }
private static void SetFormatting(IPropertySource source, PropertyItem item) { var formatterTypeAttr = source.GetAttribute<FormatterTypeAttribute>(); var enumType = source.EnumType; var valueType = source.ValueType; var basedOnField = source.BasedOnField; if (formatterTypeAttr == null) { if (enumType != null) { item.FormatterType = "Enum"; item.FormatterParams["enumKey"] = EnumMapper.GetEnumTypeKey(enumType); } else if (valueType == typeof(DateTime) || valueType == typeof(DateTime?)) { if (!ReferenceEquals(null, basedOnField) && basedOnField is DateTimeField) { switch (((DateTimeField)basedOnField).DateTimeKind) { case DateTimeKind.Unspecified: item.FormatterType = "Date"; break; default: item.FormatterType = "DateTime"; break; } } else item.FormatterType = "Date"; } else if (valueType == typeof(Boolean)) item.FormatterType = "Checkbox"; else if (valueType == typeof(Decimal) || valueType == typeof(Double) || valueType == typeof(Single) || valueType == typeof(Int32)) { item.FormatterType = "Number"; } } else { item.FormatterType = formatterTypeAttr.FormatterType; formatterTypeAttr.SetParams(item.FormatterParams); } var displayFormatAttr = source.GetAttribute<DisplayFormatAttribute>(); if (displayFormatAttr != null) { item.DisplayFormat = displayFormatAttr.Value; item.FormatterParams["displayFormat"] = displayFormatAttr.Value; } foreach (FormatterOptionAttribute param in source.GetAttributes<FormatterOptionAttribute>()) { var key = param.Key; if (key != null && key.Length >= 1) key = key.Substring(0, 1).ToLowerInvariant() + key.Substring(1); item.FormatterParams[key] = param.Value; } }
private void SetOneWay(IPropertySource source, PropertyItem item) { var attr = source.GetAttribute<OneWayAttribute>(); if (attr != null) item.OneWay = true; }
private void SetCssClass(IPropertySource source, PropertyItem item) { var attr = source.GetAttribute<CssClassAttribute>(); if (attr != null) item.CssClass = attr.CssClass; }
private void SetReadOnly(IPropertySource source, PropertyItem item) { var attr = source.GetAttribute<ReadOnlyAttribute>(); if (attr != null) item.ReadOnly = true; }
/// <summary> /// 改变的数据包含单一的对象 /// </summary> /// <param name="item"></param> public PropertySourceEventArgs(IPropertySource item) { List<IPropertySource> items = new List<IPropertySource>(); items.Add(item); this.Items = items; }
private void SetHideOnUpdate(IPropertySource source, PropertyItem item) { var attr = source.GetAttribute<HideOnUpdateAttribute>(); if (attr != null && attr.Value) item.HideOnUpdate = true; }
private void SetPlaceholder(IPropertySource source, PropertyItem item) { var attr = source.GetAttribute<PlaceholderAttribute>(); if (attr != null) item.Placeholder = attr.Value; }
private void SetAlignment(IPropertySource source, PropertyItem item) { var attr = source.GetAttribute<AlignmentAttribute>(); if (attr != null) item.Alignment = attr.Value; }
private void SetVisible(IPropertySource source, PropertyItem item) { var attr = source.GetAttribute<VisibleAttribute>(); if (attr != null && attr.Value == false) item.Visible = false; }
private void SetSortOrder(IPropertySource source, PropertyItem item) { var attr = source.GetAttribute<SortOrderAttribute>(); if (attr != null && attr.SortOrder != 0) item.SortOrder = attr.SortOrder; }
public virtual void Process(IPropertySource source, PropertyItem item) { }
private static void SetFiltering(IPropertySource source, PropertyItem item) { var filterOnlyAttr = source.GetAttribute<FilterOnlyAttribute>(); var notFilterableAttr = source.GetAttribute<NotFilterableAttribute>(); if (filterOnlyAttr != null && filterOnlyAttr.Value) item.FilterOnly = true; if (notFilterableAttr != null && notFilterableAttr.Value) item.NotFilterable = true; if (item.NotFilterable == true) return; var basedOnField = source.BasedOnField; Field idField; string idFieldName; var filteringIdField = source.GetAttribute<FilteringIdFieldAttribute>(); if (filteringIdField != null) { idFieldName = filteringIdField.Value; idField = basedOnField.Fields.FindFieldByPropertyName(idFieldName) ?? basedOnField.Fields.FindField(idFieldName); } else { idFieldName = AutoDetermineIdField(basedOnField); idField = null; if (idFieldName != null) { idField = basedOnField.Fields.FindFieldByPropertyName(idFieldName) ?? basedOnField.Fields.FindField(idFieldName); if (Object.ReferenceEquals(idField, null) || (idField.TextualField != basedOnField.PropertyName && idField.TextualField != basedOnField.Name)) { idField = null; idFieldName = null; } } } var valueType = source.ValueType; var filteringTypeAttr = source.GetAttribute<FilteringTypeAttribute>() ?? idField.GetAttribute<FilteringTypeAttribute>(); if (filteringTypeAttr == null) { var editorAttr = source.GetAttribute<EditorTypeAttribute>() ?? idField.GetAttribute<EditorTypeAttribute>(); if (idFieldName != null) { item.FilteringParams["idField"] = idFieldName; item.FilteringIdField = idFieldName; } if (editorAttr != null && !standardFilteringEditors.Contains(editorAttr.EditorType)) { if (editorAttr is LookupEditorAttribute || editorAttr is AsyncLookupEditorAttribute) { var async = editorAttr as AsyncLookupEditorAttribute; item.FilteringType = async != null ? "AsyncLookup" : "Lookup"; item.FilteringParams["lookupKey"] = async != null ? async.LookupKey : ((LookupEditorAttribute)editorAttr).LookupKey; } else { item.FilteringType = "Editor"; item.FilteringParams["editorType"] = editorAttr.EditorType; item.FilteringParams["useLike"] = source.ValueType == typeof(String); } } else if (source.EnumType != null) { item.FilteringType = "Enum"; item.FilteringParams["enumKey"] = EnumMapper.GetEnumTypeKey(source.EnumType); } else if (valueType == typeof(DateTime)) { if (!ReferenceEquals(null, basedOnField) && basedOnField is DateTimeField) { switch (((DateTimeField)basedOnField).DateTimeKind) { case DateTimeKind.Unspecified: item.FilteringType = "Date"; break; default: item.FilteringType = "DateTime"; break; } } else item.FilteringType = "Date"; } else if (valueType == typeof(Boolean)) item.FilteringType = "Boolean"; else if (valueType == typeof(Decimal) || valueType == typeof(Double) || valueType == typeof(Single)) { item.FilteringType = "Decimal"; } else if (valueType == typeof(Int32) || valueType == typeof(Int16) || valueType == typeof(Int64)) { item.FilteringType = "Integer"; } else item.FilteringType = "String"; } else { item.FilteringType = filteringTypeAttr.FilteringType; filteringTypeAttr.SetParams(item.FilteringParams); if (item.FilteringType == "Editor") { if (!item.FilteringParams.ContainsKey("editorType")) { var editorAttr =source.GetAttribute<EditorTypeAttribute>() ?? idField.GetAttribute<EditorTypeAttribute>(); if (editorAttr != null) item.FilteringParams["editorType"] = editorAttr.EditorType; } if (!item.FilteringParams.ContainsKey("useLike")) { if (valueType == typeof(String)) item.FilteringParams["useLike"] = true; } } object idFieldObj; if (item.FilteringParams.TryGetValue("idField", out idFieldObj) && idFieldObj is string) item.FilteringIdField = (idFieldObj as string).TrimToNull(); else item.FilteringIdField = idFieldName; } var displayFormatAttr = source.GetAttribute<DisplayFormatAttribute>(); if (displayFormatAttr != null) item.FilteringParams["displayFormat"] = displayFormatAttr.Value; foreach (var param in idField.GetAttributes<FilteringOptionAttribute>().Concat( source.GetAttributes<FilteringOptionAttribute>())) { var key = param.Key; if (key != null && key.Length >= 1) key = key.Substring(0, 1).ToLowerInvariant() + key.Substring(1); if (key == "idField") item.FilteringIdField = (param.Value as string) ?? item.FilteringIdField; item.FilteringParams[key] = param.Value; } }
private void SetHint(IPropertySource source, PropertyItem item) { var attr = source.GetAttribute<HintAttribute>(); if (attr != null) item.Hint = attr.Hint; }