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;
            }
        }
Beispiel #2
0
        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 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 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;
        }
Beispiel #6
0
        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;
        }
Beispiel #7
0
        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;
            }
        }
Beispiel #8
0
        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 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 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;
 }
Beispiel #11
0
        private void SetSortOrder(IPropertySource source, PropertyItem item)
        {
            var attr = source.GetAttribute <SortOrderAttribute>();

            if (attr != null && attr.SortOrder != 0)
            {
                item.SortOrder = attr.SortOrder;
            }
        }
        private void SetOneWay(IPropertySource source, PropertyItem item)
        {
            var attr = source.GetAttribute <OneWayAttribute>();

            if (attr != null)
            {
                item.OneWay = true;
            }
        }
        private void SetVisible(IPropertySource source, PropertyItem item)
        {
            var attr = source.GetAttribute <VisibleAttribute>();

            if (attr != null && attr.Value == false)
            {
                item.Visible = false;
            }
        }
        private void SetGrouping(IPropertySource source, PropertyItem item)
        {
            var groupOrderAttr = source.GetAttribute <GroupOrderAttribute>();

            if (groupOrderAttr != null && groupOrderAttr.GroupOrder != 0)
            {
                item.GroupOrder = groupOrderAttr.GroupOrder;
            }
        }
Beispiel #15
0
        private void SetAlignment(IPropertySource source, PropertyItem item)
        {
            var attr = source.GetAttribute <AlignmentAttribute>();

            if (attr != null)
            {
                item.Alignment = attr.Value;
            }
        }
        private void SetPlaceholder(IPropertySource source, PropertyItem item)
        {
            var attr = source.GetAttribute <PlaceholderAttribute>();

            if (attr != null)
            {
                item.Placeholder = attr.Value;
            }
        }
Beispiel #17
0
        private void SetAllowHide(IPropertySource source, PropertyItem item)
        {
            var attr = source.GetAttribute <AllowHideAttribute>();

            if (attr != null && attr.Value == false)
            {
                item.AllowHide = false;
            }
        }
        private void SetFormCssClass(IPropertySource source, PropertyItem item)
        {
            var attr = source.GetAttribute <FormCssClassAttribute>();

            if (attr != null)
            {
                item.FormCssClass = attr.Value;
            }
        }
        private void SetHint(IPropertySource source, PropertyItem item)
        {
            var attr = source.GetAttribute <HintAttribute>();

            if (attr != null)
            {
                item.Hint = attr.Hint;
            }
        }
        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 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 SetFormCssClass(IPropertySource source, PropertyItem item)
        {
            var cssClass = source.GetAttribute <FormCssClassAttribute>() ?? formCssClassPrior;

            if (cssClass != null)
            {
                if (!string.IsNullOrEmpty(cssClass.Value))
                {
                    if (!string.IsNullOrEmpty(item.FormCssClass))
                    {
                        item.FormCssClass = " " + cssClass.Value;
                    }
                    else
                    {
                        item.FormCssClass = cssClass.Value;
                    }
                }

                formCssClassPrior = cssClass.UntilNext ? cssClass : null;
            }

            var width = source.GetAttribute <FormWidthAttribute>() ?? formWidthPrior;

            if (width != null)
            {
                if (!string.IsNullOrEmpty(width.Value))
                {
                    if (!string.IsNullOrEmpty(item.FormCssClass))
                    {
                        item.FormCssClass += " " + width.Value;
                    }
                    else
                    {
                        item.FormCssClass = width.Value;
                    }
                }

                if (!width.JustThis)
                {
                    formWidthPrior = width.UntilNext ? width : 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;
     }
 }
Beispiel #25
0
        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 SetSummaryType(IPropertySource source, PropertyItem item)
        {
            var summaryTypeAttr = source.GetAttribute <SummaryTypeAttribute>();

            if (summaryTypeAttr == null)
            {
                if (source.GetAttribute <PrimaryKeyAttribute>() != null ||
                    source.GetAttribute <IdentityAttribute>() != null ||
                    source.GetAttribute <ForeignKeyAttribute>() != null ||
                    source.GetAttribute <LeftJoinAttribute>() != null)
                {
                    return;
                }

                var valueType = source.ValueType;
                if (valueType == typeof(decimal) ||
                    valueType == typeof(double) ||
                    valueType == typeof(float) ||
                    valueType == typeof(long) ||
                    valueType == typeof(int) ||
                    valueType == typeof(short))
                {
                    item.SummaryType = SummaryType.Sum;
                    return;
                }

                if (valueType != typeof(string) &&
                    valueType != typeof(bool) &&
                    valueType != typeof(Stream) &&
                    valueType != typeof(Guid) &&
                    valueType != typeof(DateTime) &&
                    valueType != typeof(TimeSpan))
                {
                    item.SummaryType = SummaryType.None;
                    return;
                }
            }
            else if (summaryTypeAttr.Value != SummaryType.Disabled)
            {
                item.SummaryType = summaryTypeAttr.Value;
            }
        }
Beispiel #27
0
        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 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 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;
        }
Beispiel #30
0
        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 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;
     }
 }
        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;
            }
        }
        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 SetRequired(IPropertySource source, PropertyItem item)
        {
            var attr = source.GetAttribute <RequiredAttribute>();

            if (attr != null)
            {
                if (attr.IsRequired)
                {
                    item.Required = true;
                }
            }
            else if (source.BasedOnField is object &&
                     (source.BasedOnField.Flags & FieldFlags.NotNull) == FieldFlags.NotNull)
            {
                item.Required = true;
            }
        }
Beispiel #35
0
        public override void Process(IPropertySource source, PropertyItem item)
        {
            var attr = source.GetAttribute <LocalizableAttribute>();

            if (attr != null)
            {
                if (attr.IsLocalizable)
                {
                    item.Localizable = true;
                }

                return;
            }

            if (source.BasedOnField is object &&
                IsLocalized(source.BasedOnField))
            {
                item.Localizable = true;
            }
        }
Beispiel #36
0
        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 (basedOnField is object &&
                        basedOnField is DateTimeField dtf &&
                        !dtf.DateOnly)
                    {
                        item.FormatterType = "DateTime";
                    }
                    else
                    {
                        item.FormatterType = "Date";
                    }
                }
                else if (valueType == typeof(bool))
                {
                    item.FormatterType = "Checkbox";
                }
                else if (valueType == typeof(decimal) ||
                         valueType == typeof(double) ||
                         valueType == typeof(float) ||
                         valueType == typeof(int))
                {
                    item.FormatterType = "Number";
                }
            }
        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 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 quickFilterAttr = source.GetAttribute <QuickFilterAttribute>();

            if (quickFilterAttr != null)
            {
                item.QuickFilter = true;
                if (quickFilterAttr.Separator)
                {
                    item.QuickFilterSeparator = true;
                }

                if (!string.IsNullOrEmpty(quickFilterAttr.CssClass))
                {
                    item.QuickFilterCssClass = quickFilterAttr.CssClass;
                }
            }

            var basedOnField = source.BasedOnField;

            if (!ReferenceEquals(null, basedOnField) &&
                notFilterableAttr == null)
            {
                if (basedOnField.Flags.HasFlag(FieldFlags.DenyFiltering) ||
                    basedOnField.Flags.HasFlag(FieldFlags.NotMapped))
                {
                    item.NotFilterable = true;
                }
            }

            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>();

                Action <string[]> copyParamsFromEditor = (keys) =>
                {
                    var prm = new Dictionary <string, object>();
                    editorAttr.SetParams(prm);
                    SetServiceLookupParams(editorAttr, prm);
                    foreach (var key in keys)
                    {
                        if (prm.TryGetValue(key, out object o))
                        {
                            item.FilteringParams[key] = o;
                        }
                    }
                };

                if (idFieldName != null)
                {
                    item.FilteringParams["idField"] = idFieldName;
                    item.FilteringIdField           = idFieldName;
                }

                if (editorAttr != null && !standardFilteringEditors.Contains(editorAttr.EditorType))
                {
                    if (editorAttr is LookupEditorAttribute lea)
                    {
                        item.FilteringType = "Lookup";
                        copyParamsFromEditor(lookupCopyToFilterParams);
                    }
                    else if (editorAttr is ServiceLookupEditorAttribute slea)
                    {
                        item.FilteringType = "ServiceLookup";
                        copyParamsFromEditor(serviceLookupCopyToFilterParams);
                    }
                    else
                    {
                        item.FilteringType = "Editor";
                        item.FilteringParams["editorType"] = editorAttr.EditorType;
                        item.FilteringParams["useLike"]    = source.ValueType == typeof(String);
                        if (editorAttr is LookupEditorBaseAttribute leba &&
                            leba.Async == true)
                        {
                            item.FilteringParams["async"] = true;
                        }
                    }
                }
                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 &&
                        !((DateTimeField)basedOnField).DateOnly)
                    {
                        item.FilteringType = "DateTime";
                    }
                    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 (FilteringOptionAttribute 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;
            }

            foreach (QuickFilterOptionAttribute param in
                     idField.GetAttributes <QuickFilterOptionAttribute>().Concat(
                         source.GetAttributes <QuickFilterOptionAttribute>()))
            {
                var key = param.Key;
                if (key != null &&
                    key.Length >= 1)
                {
                    key = key.Substring(0, 1).ToLowerInvariant() + key.Substring(1);
                }

                item.QuickFilterParams[key] = param.Value;
            }
        }
 private void SetReadOnly(IPropertySource source, PropertyItem item)
 {
     var attr = source.GetAttribute<ReadOnlyAttribute>();
     if (attr != null)
         item.ReadOnly = true;
 }
 private void SetCssClass(IPropertySource source, PropertyItem item)
 {
     var attr = source.GetAttribute<CssClassAttribute>();
     if (attr != null)
         item.CssClass = attr.CssClass;
 }
 private void SetSortOrder(IPropertySource source, PropertyItem item)
 {
     var attr = source.GetAttribute<SortOrderAttribute>();
     if (attr != null && attr.SortOrder != 0)
         item.SortOrder = attr.SortOrder;
 }
 private void SetAlignment(IPropertySource source, PropertyItem item)
 {
     var attr = source.GetAttribute<AlignmentAttribute>();
     if (attr != null)
         item.Alignment = attr.Value;
 }
 private void SetPlaceholder(IPropertySource source, PropertyItem item)
 {
     var attr = source.GetAttribute<PlaceholderAttribute>();
     if (attr != null)
         item.Placeholder = attr.Value;
 }
        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 (item.EditorType == "Lookup" &&
                    !item.EditorParams.ContainsKey("lookupKey"))
                {
                    var distinct = source.GetAttribute <DistinctValuesEditorAttribute>();
                    if (distinct != null)
                    {
                        string prefix = null;
                        if (distinct.RowType != null)
                        {
                            if (!distinct.RowType.IsInterface &&
                                !distinct.RowType.IsAbstract &&
                                distinct.RowType.IsSubclassOf(typeof(Row)))
                            {
                                prefix = ((Row)Activator.CreateInstance(distinct.RowType))
                                         .GetFields().LocalTextPrefix;
                            }
                        }
                        else
                        {
                            var isRow = source.Property != null &&
                                        source.Property.ReflectedType != null &&
                                        !source.Property.ReflectedType.IsAbstract &&
                                        source.Property.ReflectedType.IsSubclassOf(typeof(Row));

                            if (!isRow)
                            {
                                if (!ReferenceEquals(null, source.BasedOnField))
                                {
                                    prefix = source.BasedOnField.Fields.LocalTextPrefix;
                                }
                            }
                            else
                            {
                                prefix = ((Row)Activator.CreateInstance(source.Property.ReflectedType))
                                         .GetFields().LocalTextPrefix;
                            }
                        }

                        if (prefix != null)
                        {
                            var propertyName = distinct.PropertyName.IsEmptyOrNull() ?
                                               (!ReferenceEquals(null, source.BasedOnField) ?
                                                (source.BasedOnField.PropertyName ?? source.BasedOnField.Name) :
                                                item.Name) : distinct.PropertyName;

                            if (!string.IsNullOrEmpty(propertyName))
                            {
                                item.EditorParams["lookupKey"] = "Distinct." + prefix + "." + propertyName;
                            }
                        }
                    }
                }
            }

            if (source.EnumType != null)
            {
                item.EditorParams["enumKey"] = EnumMapper.GetEnumTypeKey(source.EnumType);
            }

            var dtka = source.GetAttribute <DateTimeKindAttribute>();

            if (dtka != null && dtka.Value != DateTimeKind.Unspecified)
            {
                item.EditorParams["useUtc"] = true;
            }

            if (!ReferenceEquals(null, source.BasedOnField))
            {
                if (dtka == null &&
                    source.BasedOnField is DateTimeField &&
                    ((DateTimeField)source.BasedOnField).DateTimeKind != DateTimeKind.Unspecified)
                {
                    item.EditorParams["useUtc"] = true;
                }

                if (item.EditorType == "Decimal" &&
                    (source.BasedOnField is DoubleField ||
                     source.BasedOnField is SingleField ||
                     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');

                    if ((item.EditorParams.ContainsKey("allowNegatives") &&
                         Convert.ToBoolean(item.EditorParams["allowNegatives"] ?? false) == true) ||
                        (!item.EditorParams.ContainsKey("allowNegatives") &&
                         DecimalEditorAttribute.AllowNegativesByDefault))
                    {
                        minVal = "-" + maxVal;
                    }

                    item.EditorParams["minValue"] = minVal;
                    item.EditorParams["maxValue"] = maxVal;
                }
                else if (item.EditorType == "Integer" &&
                         (source.BasedOnField is Int32Field ||
                          source.BasedOnField is Int16Field ||
                          source.BasedOnField is Int64Field) &&
                         !item.EditorParams.ContainsKey("minValue") &&
                         !item.EditorParams.ContainsKey("maxValue"))
                {
                    item.EditorParams["maxValue"] = source.BasedOnField is Int16Field ? Int16.MaxValue
                        : source.BasedOnField is Int32Field ? Int32.MaxValue :
                                                    source.BasedOnField is Int64Field ? Int64.MaxValue : (object)null;

                    if ((item.EditorParams.ContainsKey("allowNegatives") &&
                         Convert.ToBoolean(item.EditorParams["allowNegatives"] ?? false) == true) ||
                        (!item.EditorParams.ContainsKey("allowNegatives") &&
                         DecimalEditorAttribute.AllowNegativesByDefault) &&
                        item.EditorParams["maxValue"] != null)
                    {
                        item.EditorParams["minValue"] = -Convert.ToInt64(item.EditorParams["maxValue"]) - 1;
                    }
                }
                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;
            }

            SetServiceLookupParams(editorTypeAttr, item.EditorParams);
        }
 private void SetOneWay(IPropertySource source, PropertyItem item)
 {
     var attr = source.GetAttribute<OneWayAttribute>();
     if (attr != null)
         item.OneWay = true;
 }
 private void SetHint(IPropertySource source, PropertyItem item)
 {
     var attr = source.GetAttribute<HintAttribute>();
     if (attr != null)
         item.Hint = attr.Hint;
 }
        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 SetVisible(IPropertySource source, PropertyItem item)
 {
     var attr = source.GetAttribute<VisibleAttribute>();
     if (attr != null && attr.Value == false)
         item.Visible = false;
 }
        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 quickFilterAttr = source.GetAttribute <QuickFilterAttribute>();

            if (quickFilterAttr != null)
            {
                item.QuickFilter = true;
                if (quickFilterAttr.Separator)
                {
                    item.QuickFilterSeparator = true;
                }

                if (!string.IsNullOrEmpty(quickFilterAttr.CssClass))
                {
                    item.QuickFilterCssClass = quickFilterAttr.CssClass;
                }
            }

            var basedOnField = source.BasedOnField;

            if (basedOnField is object &&
                notFilterableAttr == null)
            {
                if (basedOnField.Flags.HasFlag(FieldFlags.DenyFiltering) ||
                    basedOnField.Flags.HasFlag(FieldFlags.NotMapped))
                {
                    item.NotFilterable = true;
                }
            }

            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 (idField is 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>();

                void copyParamsFromEditor(string[] keys)
                {
                    var prm = new Dictionary <string, object>();

                    editorAttr.SetParams(prm);
                    SetServiceLookupParams(editorAttr, prm);
                    foreach (var key in keys)
                    {
                        if (prm.TryGetValue(key, out object o))
                        {
                            item.FilteringParams[key] = o;
                        }
                    }
                }

                if (idFieldName != null)
                {
                    item.FilteringParams["idField"] = idFieldName;
                    item.FilteringIdField           = idFieldName;
                }

                if (editorAttr != null && !standardFilteringEditors.Contains(editorAttr.EditorType))
                {
                    if (editorAttr is LookupEditorAttribute)
                    {
                        item.FilteringType = "Lookup";
                        copyParamsFromEditor(lookupCopyToFilterParams);
                    }
                    else if (editorAttr is ServiceLookupEditorAttribute)
                    {
                        item.FilteringType = "ServiceLookup";
                        copyParamsFromEditor(serviceLookupCopyToFilterParams);
                    }
                    else
                    {
                        item.FilteringType = "Editor";
                        item.FilteringParams["editorType"] = editorAttr.EditorType;
                        item.FilteringParams["useLike"]    = source.ValueType == typeof(string);
                        if (editorAttr is LookupEditorBaseAttribute leba &&
                            leba.Async == true)
                        {
                            item.FilteringParams["async"] = true;
                        }
                    }
                }
                else if (source.EnumType != null)
                {
                    item.FilteringType = "Enum";
                    item.FilteringParams["enumKey"] = EnumMapper.GetEnumTypeKey(source.EnumType);
                }
                else if (valueType == typeof(DateTime))
                {
                    if (basedOnField is object &&
                        basedOnField is DateTimeField dtf &&
                        !dtf.DateOnly)
                    {
                        item.FilteringType = "DateTime";
                    }
                    else
                    {
                        item.FilteringType = "Date";
                    }
                }
                else if (valueType == typeof(bool))
                {
                    item.FilteringType = "Boolean";
                }
                else if (valueType == typeof(decimal) ||
                         valueType == typeof(double) ||
                         valueType == typeof(float))
                {
                    item.FilteringType = "Decimal";
                }
                else if (valueType == typeof(int) ||
                         valueType == typeof(short) ||
                         valueType == typeof(long))
                {
                    item.FilteringType = "Integer";
                }
                else
                {
                    item.FilteringType = "String";
                }
            }
 private void SetHideOnUpdate(IPropertySource source, PropertyItem item)
 {
     var attr = source.GetAttribute<HideOnUpdateAttribute>();
     if (attr != null && attr.Value)
         item.HideOnUpdate = true;
 }
        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;
            }
        }