예제 #1
0
            public TypeConfiguration(InputBuilder inputBuilder)
            {
                if (inputBuilder == null)
                {
                    throw new ArgumentNullException("inputBuilder");
                }

                _inputBuilder = inputBuilder;
                Text();
            }
예제 #2
0
        private static InputBuilder UnobtrusiveValidationAttributes <TModel, TProperty>(this BootstrapFactory <TModel> factory, InputBuilder builder, Expression <Func <TModel, TProperty> > expression)
        {
            var htmlHelper = factory.HtmlHelper;

            var name = ExpressionHelper.GetExpressionText(expression);

            var fullHtmlFieldName = htmlHelper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(name);

            var modelMetadata = ModelMetadata.FromLambdaExpression(expression, htmlHelper.ViewData);
            var attributes    = htmlHelper.GetUnobtrusiveValidationAttributes(name, modelMetadata);

            var value = htmlHelper.FormatValue(modelMetadata.Model, null);

            builder.Id(fullHtmlFieldName).Name(fullHtmlFieldName).Value(value);

            foreach (var attribute in attributes)
            {
                builder.Attribute(attribute.Key, attribute.Value.ToString(), true);
            }

            return(builder);
        }