public void Setup()
        {
            _fc = Substitute.For<IFieldConfiguration>();

            _f = Substitute.For<IForm<TestFieldViewModel, IFormTemplate>>();
            _f.Template.BeginField(_label, _field, _validation, _metadata, Arg.Any<IReadonlyFieldConfiguration>(), Arg.Any<bool>()).Returns(_beginHtml);
            _f.Template.Field(_label, _field, _validation, _metadata, Arg.Any<IReadonlyFieldConfiguration>(), Arg.Any<bool>()).Returns(_html);
            _f.Template.EndField().Returns(_endHtml);

            _g = Substitute.For<IFieldGenerator>();
            _g.GetLabelHtml(Arg.Any<IReadonlyFieldConfiguration>()).Returns(_label);
            _g.GetFieldHtml(Arg.Any<IReadonlyFieldConfiguration>()).Returns(_field);
            _g.GetValidationHtml(Arg.Any<IReadonlyFieldConfiguration>()).Returns(_validation);
            _g.Metadata.Returns(_metadata);
            _g.GetFieldId().Returns(FieldId);

            var autoSubstitute = AutoSubstituteContainer.Create();
            var helper = autoSubstitute.Resolve<HtmlHelpers<TestFieldViewModel>>();
            _f.HtmlHelper.Returns(helper);
            _f.GetFieldGenerator(Arg.Any<Expression<Func<TestFieldViewModel, string>>>()).Returns(_g);
        }
Example #2
0
        /// <inheritdoc />
        public IReadonlyFieldConfiguration PrepareFieldConfiguration(IFieldConfiguration fieldConfiguration, FieldParent fieldParent)
        {
            fieldConfiguration = fieldConfiguration ?? new FieldConfiguration();
            if (!string.IsNullOrEmpty(Metadata.EditFormatString) && string.IsNullOrEmpty(fieldConfiguration.FormatString))
            {
                fieldConfiguration.WithFormatString(Metadata.EditFormatString);
            }
            if (!string.IsNullOrEmpty(Metadata.NullDisplayText) && string.IsNullOrEmpty(fieldConfiguration.NoneString))
            {
                fieldConfiguration.WithNoneAs(Metadata.NullDisplayText);
            }
            if (Metadata.IsReadOnly)
            {
                fieldConfiguration.Readonly();
            }

            var handler = FieldGeneratorHandlersRouter <TModel, T> .GetHandler(this);

            handler.PrepareFieldConfiguration(fieldConfiguration);
            Template.PrepareFieldConfiguration(this, handler, fieldConfiguration, fieldParent);

            return(fieldConfiguration);
        }
Example #3
0
        private void AddRangeRule(IFieldDefinition <T> definition, IFieldConfiguration <T> configuration, ValidationPropertyInfo validationProperty)
        {
            var rule = validationProperty.Rules.FirstOrDefault(r => r.Rule == "Range");

            if (rule == null)
            {
                rule = new ValidationRule {
                    Rule = "Range"
                };
                validationProperty.Rules.Add(rule);
            }

            var typeInteger = definition.FieldType == FieldType.NumberInteger;

            if (configuration.ConfigurationType == FieldConfigurationType.Minimum)
            {
                rule.Minimum = typeInteger ? Convert.ToDecimal(configuration.ValueInteger) : configuration.ValueDecimal ?? 0m;
            }
            else
            {
                rule.Maximum = typeInteger ? Convert.ToDecimal(configuration.ValueInteger) : configuration.ValueDecimal ?? 0m;
            }
        }
 public void Setup()
 {
     _fieldConfiguration = new FieldConfiguration();
 }
 public void Setup()
 {
     config = new FieldConfiguration();
     form   = new LicenceApplicationFormDefinition(config);
 }
Example #6
0
        /// <inheritdoc />
        public override void PrepareFieldConfiguration <TModel, T>(IFieldGenerator <TModel, T> fieldGenerator, IFieldGeneratorHandler <TModel, T> fieldGeneratorHandler, IFieldConfiguration fieldConfiguration, FieldParent fieldParent)
        {
            if (fieldParent == FieldParent.Form)
            {
                return;
            }

            fieldConfiguration.AddValidationClass("help-block");

            var displayType = fieldGeneratorHandler.GetDisplayType(fieldConfiguration.ToReadonly());

            if (NormalFieldTypes.Contains(displayType))
            {
                fieldConfiguration.Bag.CanBeInputGroup = true;
                fieldConfiguration.AddClass("form-control").AddLabelClass("control-label");
            }

            if (displayType == FieldDisplayType.Checkbox)
            {
                fieldConfiguration.Bag.IsCheckboxControl = true;
                // Hide the parent label otherwise it looks weird
                fieldConfiguration.Label("").WithoutLabel();
            }

            if (displayType == FieldDisplayType.List)
            {
                fieldConfiguration.Bag.IsRadioOrCheckboxList = true;
            }
        }
 /// <summary>
 /// Creates a <see cref="ReadonlyFieldConfiguration"/> that wraps the provided <see cref="IFieldConfiguration"/>.
 /// </summary>
 /// <param name="fieldConfiguration">The field configuration to wrap</param>
 public ReadonlyFieldConfiguration(IFieldConfiguration fieldConfiguration)
 {
     _fieldConfiguration = fieldConfiguration ?? new FieldConfiguration();
 }
Example #8
0
 /// <summary>
 /// Outputs the field in an input group using prepended and appended HTML.
 /// </summary>
 /// <example>
 /// @n.Field(labelHtml, elementHtml, validationHtml, metadata, new FieldConfiguration().Prepend(beforeHtml).Append(afterHtml).AsInputGroup(), false)
 /// </example>
 /// <param name="fc">The configuration for a field</param>
 /// <returns>The field configuration object to allow for method chaining</returns>
 public static IFieldConfiguration AsInputGroup(this IFieldConfiguration fc)
 {
     fc.Bag.DisplayAsInputGroup = true;
     return(fc);
 }
Example #9
0
        /// <summary>
        /// Adds a filter to the specified search requiring that the specified field is in the specified range.
        /// </summary>
        /// <param name="search">The search to modify.</param>
        /// <param name="field">The field to filter on.</param>
        /// <param name="from">The value for the lower end of the range, represented as a string in the invariant culture.</param>
        /// <param name="to">The value for the upper end of the range, represented as a string in the invariant culture.</param>
        /// <param name="includeFrom">If true, the lower endpoint is included; otherwise, it is excluded.</param>
        /// <param name="includeTo">If true, the upper endpoint is included; otherwise, it is excluded.</param>
        /// <returns>The search, modified to include the requested filter.</returns>
        public static ITypeSearch <FindDocument> FilterFieldRange(this ITypeSearch <FindDocument> search, IFieldConfiguration field, string from, string to, bool includeFrom, bool includeTo)
        {
            Expression <Func <FindDocument, Filter> > rangeFilter = UntypedFilterBuilder.GetRangeFilter(field, from, to, includeFrom, includeTo);

            return(search.Filter <FindDocument>(rangeFilter));
        }
Example #10
0
        /// <summary>
        /// Adds a filter to the specified search requiring that the specified price field is in the specified range.
        /// </summary>
        /// <param name="search">The search to modify.</param>
        /// <param name="fieldName">The name of the field to filter on.  This should be "listprice" or "saleprice".</param>
        /// <param name="currency">The currency of the price to filter on.</param>
        /// <param name="marketId">The market id.</param>
        /// <param name="from">The value for the lower end of the range.</param>
        /// <param name="to">The value for the upper end of the range.</param>
        /// <param name="includeFrom">If true, the lower endpoint is included; otherwise, it is excluded.</param>
        /// <param name="includeTo">If true, the upper endpoint is included; otherwise, it is excluded.</param>
        /// <returns>The search, modified to include the requested filter.</returns>
        public static ITypeSearch <FindDocument> FilterPriceFieldRange(this ITypeSearch <FindDocument> search, string fieldName, string currency, MarketId marketId, double?from, double?to, bool includeFrom, bool includeTo)
        {
            IFieldConfiguration <double?> priceField = search.Client.GetPriceField(fieldName, currency, marketId);

            return(search.FilterFieldRange((IFieldConfiguration)priceField, from.HasValue ? from.Value.ToString((IFormatProvider)CultureInfo.InvariantCulture) : string.Empty, to.HasValue ? to.Value.ToString((IFormatProvider)CultureInfo.InvariantCulture) : string.Empty, includeFrom, includeTo));
        }
Example #11
0
        /// <summary>
        /// Adds a filter to the specified search requiring that the specified field is in the specified range.
        /// </summary>
        /// <param name="search">The search to modify.</param>
        /// <param name="fieldName">The name of the field to filter on.</param>
        /// <param name="locale">The locale of the field to filter on. If the field is not multilanguage, locale is ignored. If locale is null, the field may not be multilanguage.</param>
        /// <param name="from">The value for the lower end of the range, represented as a string in the invariant culture.</param>
        /// <param name="to">The value for the upper end of the range, represented as a string in the invariant culture.</param>
        /// <param name="includeFrom">If true, the lower endpoint is included; otherwise, it is excluded.</param>
        /// <param name="includeTo">If true, the upper endpoint is included; otherwise, it is excluded.</param>
        /// <returns>The search, modified to include the requested filter.</returns>
        public static ITypeSearch <FindDocument> FilterFieldRange <TField>(this ITypeSearch <FindDocument> search, string fieldName, string locale, string from, string to, bool includeFrom, bool includeTo)
        {
            IFieldConfiguration <TField> field = search.Client.GetField <TField>(fieldName, locale);

            return(search.FilterFieldRange((IFieldConfiguration)field, from, to, includeFrom, includeTo));
        }
Example #12
0
 public LicenceApplicationFormDefinition(IFieldConfiguration fieldConfiguration)
 {
     this.fieldConfiguration = fieldConfiguration;
 }
Example #13
0
 public IFieldConfiguration Field(IHtmlContent labelHtml, IHtmlContent elementHtml, IHtmlContent validationHtml = null,
                                  ModelMetadata metadata = null, bool isValid = true, IFieldConfiguration fieldConfiguration = null)
 {
     return((_parentSection as ISection)?.Field(labelHtml, elementHtml, validationHtml, metadata, isValid, fieldConfiguration));
 }
Example #14
0
        public void Pass_lazy_initialised_field_into_field_configuration()
        {
            _fc = new FieldConfiguration();
            var field = Arrange(false);
            _fc.SetField(() => field);

            Assert.That(_fc.ToHtmlString(), Is.EqualTo(field.ToHtmlString()));
        }
Example #15
0
        public void Pass_field_into_field_configuration()
        {
            _fc = new FieldConfiguration();
            var field = Arrange(false);

            Assert.That(_fc.ToHtmlString(), Is.EqualTo(field.ToHtmlString()));
        }
Example #16
0
 /// <summary>
 /// Creates a <see cref="ReadonlyFieldConfiguration"/> that wraps the provided <see cref="IFieldConfiguration"/>.
 /// </summary>
 /// <param name="fieldConfiguration">The field configuration to wrap</param>
 public ReadonlyFieldConfiguration(IFieldConfiguration fieldConfiguration)
 {
     _fieldConfiguration = fieldConfiguration ?? new FieldConfiguration();
 }
 public IFieldConfiguration ModifyConfig(IFieldConfiguration config)
 {
     if (_aslist)
         config.AsRadioList();
     return config;
 }
Example #18
0
        /// <summary>
        /// Adds the ordering requests from an ISearchCriteria object to an existing search.
        /// </summary>
        public static ITypeSearch <FindDocument> OrderBy(this ITypeSearch <FindDocument> search, ISearchCriteria criteria)
        {
            ISearchConfiguration configuration = search.Client.GetConfiguration();

            SearchSortField[] searchSortFieldArray = criteria.Sort == null ? new SearchSortField[0] : criteria.Sort.GetSort();
            bool flag = true;

            foreach (SearchSortField searchSortField in searchSortFieldArray)
            {
                IFieldConfiguration field1;
                if (configuration.TryGetAnyField(searchSortField.FieldName, criteria.Locale, criteria.Currency, criteria.MarketId, out field1) && field1 != null)
                {
                    if (field1.Type == typeof(string))
                    {
                        IFieldConfiguration <string> field2 = (IFieldConfiguration <string>)field1;
                        search = flag ? search.OrderByField <string>(field2, searchSortField.IsDescending) : search.ThenByField <string>(field2, searchSortField.IsDescending);
                    }
                    else if (field1.Type == typeof(bool?))
                    {
                        IFieldConfiguration <bool?> field2 = (IFieldConfiguration <bool?>)field1;
                        search = flag ? search.OrderByField <bool?>(field2, searchSortField.IsDescending) : search.ThenByField <bool?>(field2, searchSortField.IsDescending);
                    }
                    else if (field1.Type == typeof(int?))
                    {
                        IFieldConfiguration <int?> field2 = (IFieldConfiguration <int?>)field1;
                        search = flag ? search.OrderByField <int?>(field2, searchSortField.IsDescending) : search.ThenByField <int?>(field2, searchSortField.IsDescending);
                    }
                    else if (field1.Type == typeof(int))
                    {
                        IFieldConfiguration <int> field2 = (IFieldConfiguration <int>)field1;
                        search = flag ? search.OrderByField <int>(field2, searchSortField.IsDescending) : search.ThenByField <int>(field2, searchSortField.IsDescending);
                    }
                    else if (field1.Type == typeof(long?))
                    {
                        IFieldConfiguration <long?> field2 = (IFieldConfiguration <long?>)field1;
                        search = flag ? search.OrderByField <long?>(field2, searchSortField.IsDescending) : search.ThenByField <long?>(field2, searchSortField.IsDescending);
                    }
                    else if (field1.Type == typeof(double?))
                    {
                        IFieldConfiguration <double?> field2 = (IFieldConfiguration <double?>)field1;
                        search = flag ? search.OrderByField <double?>(field2, searchSortField.IsDescending) : search.ThenByField <double?>(field2, searchSortField.IsDescending);
                    }
                    else if (field1.Type == typeof(DateTime?))
                    {
                        IFieldConfiguration <DateTime?> field2 = (IFieldConfiguration <DateTime?>)field1;
                        search = flag ? search.OrderByField <DateTime?>(field2, searchSortField.IsDescending) : search.ThenByField <DateTime?>(field2, searchSortField.IsDescending);
                    }
                    else
                    {
                        if (!(field1.Type == typeof(DateTime)))
                        {
                            throw new InvalidOperationException(string.Format("Cannot sort on a field of type {0}.", (object)field1.Type.Name));
                        }
                        IFieldConfiguration <DateTime> field2 = (IFieldConfiguration <DateTime>)field1;
                        search = flag ? search.OrderByField <DateTime>(field2, searchSortField.IsDescending) : search.ThenByField <DateTime>(field2, searchSortField.IsDescending);
                    }
                    flag = false;
                }
            }
            return(search);
        }
Example #19
0
 /// <summary>
 /// Creates a single form field as a child of a form section that can have other form fields nested within it.
 /// </summary>
 /// <example>
 /// @using (var f = s.BeginFieldFor(m => m.Company)) {
 ///     @f.FieldFor(m => m.PositionTitle)
 /// }
 /// </example>
 /// <typeparam name="TModel">The view model type for the current view</typeparam>
 /// <typeparam name="T">The type of the field being generated</typeparam>
 /// <param name="section">The section the field is being created in</param>
 /// <param name="property">A lamdba expression to identify the field to render the field for</param>
 /// <param name="config">Any configuration information for the field</param>
 /// <returns>The form field</returns>
 public static Field <TModel> BeginFieldFor <TModel, T>(this ISection <TModel> section, Expression <Func <TModel, T> > property, IFieldConfiguration config = null)
 {
     return(new Field <TModel>(section.Form, true, section.Form.GetFieldGenerator(property), config));
 }
Example #20
0
 /// <summary>
 /// Adds a code-ordered ascending ordering request for the specified field to an existing search.
 /// </summary>
 public static ITypeSearch <FindDocument> ThenByField <TField>(this ITypeSearch <FindDocument> search, IFieldConfiguration <TField> field, bool isDescending = false)
 {
     if (!isDescending)
     {
         return(search.ThenBy <FindDocument, TField>(field.TypedGetValueExpression));
     }
     return(search.ThenByDescending <FindDocument, TField>(field.TypedGetValueExpression));
 }
 /// <summary>
 /// Evaluate value against match pattern in the supplied field configuration and return
 /// true if they match.
 /// </summary>
 /// <param name="fieldConfig"></param>
 /// <param name="value"></param>
 /// <returns></returns>
 private bool IsMatch(IFieldConfiguration fieldConfig, string value)
 {
     return(!string.IsNullOrEmpty(fieldConfig.MatchPattern) &&
            (fieldConfig.MatchPattern == "*" || Regex.IsMatch(value, fieldConfig.MatchPattern, RegexOptions.IgnoreCase)));
 }
Example #22
0
 /// <summary>
 /// Adds a code-ordered descending ordering request for the specified field to an existing search.
 /// </summary>
 public static ITypeSearch <FindDocument> ThenByFieldDescending <TField>(this ITypeSearch <FindDocument> search, IFieldConfiguration <TField> field)
 {
     return(search.ThenByField <TField>(field, true));
 }
Example #23
0
 public void Setup()
 {
     _fieldConfiguration = new FieldConfiguration();
 }
Example #24
0
        public bool TryGetPriceField(string name, Mediachase.Commerce.Currency currency, MarketId marketId, out IFieldConfiguration <double?> field)
        {
            IFieldConfiguration fieldWorker = this.TryGetFieldWorker(name, (string)null, new Mediachase.Commerce.Currency?(currency), new MarketId?(marketId));

            field = fieldWorker as IFieldConfiguration <double?>;
            return(field != null);
        }
Example #25
0
 public virtual void PrepareFieldConfiguration(IFieldConfiguration fieldConfiguration)
 {
 }
Example #26
0
 public bool TryGetAnyField(string name, string locale, Mediachase.Commerce.Currency currency, MarketId marketId, out IFieldConfiguration field)
 {
     field = this.TryGetFieldWorker(name, locale, new Mediachase.Commerce.Currency?(currency), new MarketId?(marketId));
     return(field != null);
 }
Example #27
0
 /// <inheritdoc />
 public IHtmlString GetLabelHtml(IFieldConfiguration fieldConfiguration)
 {
     return(GetLabelHtml(PrepareFieldConfiguration(fieldConfiguration, FieldParent.Form)));
 }
Example #28
0
        private IFieldConfiguration TryGetFieldWorker(string name, string locale, Mediachase.Commerce.Currency?currency, MarketId?marketId)
        {
            if (locale != null)
            {
                this.AddLocale(locale);
            }
            if (currency.HasValue)
            {
                this.AddCurrency(currency.Value);
            }
            if (marketId.HasValue)
            {
                this.AddMarket(marketId.Value);
            }
            List <IFieldConfiguration> fieldConfigurationList;

            if (!this._fieldMap.TryGetValue(name, out fieldConfigurationList))
            {
                return((IFieldConfiguration)null);
            }
            IFieldConfiguration fieldConfiguration1 = (IFieldConfiguration)null;
            IFieldConfiguration fieldConfiguration2 = (IFieldConfiguration)null;
            IFieldConfiguration fieldConfiguration3 = (IFieldConfiguration)null;

            foreach (IFieldConfiguration fieldConfiguration4 in fieldConfigurationList)
            {
                if (fieldConfiguration4.Locale == null && !fieldConfiguration4.Currency.HasValue)
                {
                    if (fieldConfiguration1 != null)
                    {
                        throw new Exception(string.Format("Multiple single-language fields found for \"{0}\".", (object)name));
                    }
                    fieldConfiguration1 = fieldConfiguration4;
                }
                else if (fieldConfiguration4.Locale != null)
                {
                    if (string.Equals(locale, fieldConfiguration4.Locale, StringComparison.OrdinalIgnoreCase))
                    {
                        if (fieldConfiguration2 != null)
                        {
                            throw new Exception(string.Format("Multiple multi-language fields found for \"{0}\", \"{1}\".", (object)name, (object)locale));
                        }
                        fieldConfiguration2 = fieldConfiguration4;
                    }
                }
                else if (fieldConfiguration4.Currency.HasValue && currency.HasValue && marketId.HasValue)
                {
                    Mediachase.Commerce.Currency?currency1 = fieldConfiguration4.Currency;
                    Mediachase.Commerce.Currency currency2 = currency.Value;
                    if ((currency1.HasValue ? (currency1.HasValue ? (currency1.GetValueOrDefault() == currency2 ? 1 : 0) : 1) : 0) != 0)
                    {
                        MarketId?marketId1 = fieldConfiguration4.MarketId;
                        MarketId marketId2 = marketId.Value;
                        if ((marketId1.HasValue ? (marketId1.HasValue ? (marketId1.GetValueOrDefault() == marketId2 ? 1 : 0) : 1) : 0) != 0)
                        {
                            if (fieldConfiguration3 != null)
                            {
                                throw new Exception(string.Format("Multiple price fields found for \"{0}\", \"{1}\", \"{2}\".", (object)name, (object)currency.Value.CurrencyCode, (object)marketId.Value.Value));
                            }
                            fieldConfiguration3 = fieldConfiguration4;
                        }
                    }
                }
            }
            IFieldConfiguration fieldConfiguration5 = fieldConfiguration2 ?? fieldConfiguration1;

            if (fieldConfiguration5 != null && fieldConfiguration3 != null)
            {
                throw new Exception(string.Format("Multiple kinds of fields found for \"{0}\", \"{1}\", \"{2}\", \"{3}\".", new object[4]
                {
                    (object)name,
                    (object)(locale ?? string.Empty),
                    marketId.HasValue ? (object)marketId.Value.Value : (object)string.Empty,
                    currency.HasValue ? (object)currency.Value.CurrencyCode : (object)string.Empty
                }));
            }
            return(fieldConfiguration5 ?? fieldConfiguration3);
        }
Example #29
0
        /// <inheritdoc />
        public IFieldConfiguration Field(IHtmlContent labelHtml, IHtmlContent elementHtml, IHtmlContent validationHtml = null, ModelMetadata metadata = null, bool isValid = true, IFieldConfiguration fieldConfiguration = null)
        {
            var fc = fieldConfiguration ?? new FieldConfiguration();

            fc.SetField(() => Form.Template.Field(labelHtml, elementHtml, validationHtml, metadata, fc, isValid));
            return(fc);
        }
Example #30
0
 public Nancy.ViewEngines.Razor.IHtmlString GetValidationHtml(IFieldConfiguration fieldConfiguration)
 {
     return(GetValidationHtml(PrepareFieldConfiguration(fieldConfiguration)));
 }
 /// <inheritdoc />
 public IHtmlContent GetValidationHtml(IFieldConfiguration fieldConfiguration)
 {
     return(GetValidationHtml(PrepareFieldConfiguration(fieldConfiguration, FieldParent.Form)));
 }
 /// <summary>
 /// Creates a single form field as a child of a form section that can have other form fields nested within it.
 /// </summary>
 /// <example>
 /// @using (var f = s.BeginFieldFor(m => m.Company)) {
 ///     @f.FieldFor(m => m.PositionTitle)
 /// }
 /// </example>
 /// <typeparam name="TModel">The view model type for the current view</typeparam>
 /// <typeparam name="TTemplate">The type of HTML template renderer the form is using</typeparam>
 /// <typeparam name="T">The type of the field being generated</typeparam>
 /// <param name="section">The section the field is being created in</param>
 /// <param name="property">A lamdba expression to identify the field to render the field for</param>
 /// <param name="config">Any configuration information for the field</param>
 /// <returns></returns>
 public static Field <TModel, TTemplate> BeginFieldFor <TModel, TTemplate, T>(this Section <TModel, TTemplate> section, Expression <Func <TModel, T> > property, IFieldConfiguration config = null) where TTemplate : IFormTemplate
 {
     return(new Field <TModel, TTemplate>(section.Form, true, section.Form.GetFieldGenerator(property), config));
 }
        private IFieldConfiguration MergeMemberConfiguration(IFieldConfiguration member, IFieldConfiguration mergedMember = null)
        {
            mergedMember = mergedMember ?? new FieldConfiguration(member.FieldMemberInfo);
            foreach (var data in member.Data)
            {
                mergedMember.Data[data.Key] = data.Value;
            }

            mergedMember.Ignored = member.Ignored ?? mergedMember.Ignored;

            mergedMember.Input  = member.Input ?? mergedMember.Input;
            mergedMember.Output = member.Output ?? mergedMember.Output;

            return(mergedMember);
        }
 public static void PrepareFieldConfiguration(IFieldGenerator <TModel, T> fieldGenerator, IFieldConfiguration fieldConfiguration)
 {
     GetHandlers(fieldGenerator, new ReadonlyFieldConfiguration(fieldConfiguration))
     .First(h => h.CanHandle())
     .PrepareFieldConfiguration(fieldConfiguration);
 }
Example #35
0
        /// <inheritdoc />
        public override void PrepareFieldConfiguration(IFieldConfiguration fieldConfiguration)
        {
            if (!fieldConfiguration.Attributes.Has("step"))
            {
                if (FieldGenerator.IsIntegralNumber())
                {
                    fieldConfiguration.Attr("step", 1);
                }
                else if (FieldGenerator.Metadata.DataTypeName == DataType.Currency.ToString())
                {
                    fieldConfiguration.Attr("step", 0.01);
                }
                else
                {
                    fieldConfiguration.Attr("step", "any");
                }
            }

            if (!fieldConfiguration.Attributes.Has("min") || !fieldConfiguration.Attributes.Has("max"))
            {
                object min = null;
                object max = null;

                if (FieldGenerator.GetCustomAttributes().OfType <RangeAttribute>().Any())
                {
                    var converter = TypeDescriptor.GetConverter(FieldGenerator.GetUnderlyingType());
                    var range     = FieldGenerator.GetCustomAttributes().OfType <RangeAttribute>().First();
                    min = range.Minimum;
                    max = range.Maximum;
                }
                else
                {
                    var type = FieldGenerator.GetUnderlyingType();

                    // https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/integral-numeric-types
                    if (type == typeof(byte))
                    {
                        min = 0;
                        max = 255;
                    }
                    if (type == typeof(sbyte))
                    {
                        min = -128;
                        max = 127;
                    }
                    if (type == typeof(short))
                    {
                        min = -32768;
                        max = 32767;
                    }
                    if (type == typeof(ushort))
                    {
                        min = 0;
                        max = 65535;
                    }
                    if (type == typeof(uint))
                    {
                        min = 0;
                    }
                    if (type == typeof(ulong))
                    {
                        min = 0;
                    }
                }

                if (!fieldConfiguration.Attributes.Has("min") && min != null)
                {
                    fieldConfiguration.Min(min.ToString());
                }
                if (!fieldConfiguration.Attributes.Has("max") && max != null)
                {
                    fieldConfiguration.Max(max.ToString());
                }
            }
        }
 /// <inheritdoc />
 public virtual void PrepareFieldConfiguration <TModel, T>(IFieldGenerator <TModel, T> fieldGenerator, IFieldGeneratorHandler <TModel, T> fieldGeneratorHandler,
                                                           IFieldConfiguration fieldConfiguration, FieldParent fieldParent)
 {
 }