示例#1
0
        private static void writeGenericGetter(TextWriter writer, ModificationField field)
        {
            CodeGenerationStatics.AddSummaryDocComment(writer, getFormItemGetterSummary(field, "", new string[0]));

            var parameters = new List <CSharpParameter>();

            parameters.Add(new CSharpParameter("System.Func<{0},IReadOnlyCollection<FlowComponent>>".FormatWith(field.NullableTypeName), "contentGetter"));
            parameters.Add(new CSharpParameter("FormItemSetup", "setup", "null"));
            parameters.Add(new CSharpParameter("IReadOnlyCollection<PhrasingComponent>", "label", "null"));
            parameters.Add(
                new CSharpParameter(
                    field.TypeIs(typeof(string)) ? field.NullableTypeName : "SpecifiedValue<{0}>".FormatWith(field.NullableTypeName),
                    "value",
                    "null"));
            parameters.Add(new CSharpParameter("System.Func<System.Action<{0}>,EwfValidation>".FormatWith(field.TypeName), "validationGetter", "null"));

            writer.WriteLine(
                "public FormItem " + EwlStatics.GetCSharpIdentifier("Get" + field.PascalCasedName + "FormItem") + "( " +
                parameters.Select(i => i.MethodSignatureDeclaration).GetCommaDelimitedStringFromCollection() + " ) {");
            writer.WriteLine("label = label ?? \"{0}\".ToComponents();".FormatWith(getDefaultLabel(field)));
            writer.WriteLine(
                "return {0}.ToFormItem( setup: setup, label: label, validation: {1} );".FormatWith(
                    "contentGetter( {0} )".FormatWith(
                        field.TypeIs(typeof(string))
                                                        ? "value ?? {0}".FormatWith(EwlStatics.GetCSharpIdentifier(field.Name))
                                                        : "value != null ? value.Value : {0}".FormatWith(EwlStatics.GetCSharpIdentifier(field.Name))),
                    "validationGetter?.Invoke( v => {0} = v )".FormatWith(EwlStatics.GetCSharpIdentifier(field.Name))));
            writer.WriteLine("}");
        }
示例#2
0
 private static void writeGuidFormItemGetters(TextWriter writer, ModificationField field)
 {
     if (!field.TypeIs(typeof(Guid)) && !field.TypeIs(typeof(Guid? )))
     {
         return;
     }
     writeNumberAsSelectListFormItemGetters(writer, field);
 }
 private static void writeBoolFormItemGetters( TextWriter writer, ModificationField field )
 {
     if( field.TypeIs( typeof( bool ) ) ) {
         writeCheckBoxFormItemGetters( writer, field, "bool" );
         writeNumberAsSelectListFormItemGetters( writer, field );
     }
     if( field.TypeIs( typeof( bool? ) ) )
         writeNumberAsSelectListFormItemGetters( writer, field );
 }
 private static void writeDateFormItemGetters(TextWriter writer, ModificationField field)
 {
     if (field.TypeIs(typeof(DateTime? )))
     {
         writeFormItemGetters(
             writer,
             field,
             "DatePicker",
             "Date",
             "System.DateTime?",
             "null",
             new CSharpParameter[0],
             new CSharpParameter[0],
             new[]
         {
             new CSharpParameter("System.DateTime?", "minDate", "null"), new CSharpParameter("System.DateTime?", "maxDate", "null"),
             new CSharpParameter("bool", "constrainToSqlSmallDateTimeRange", "true")
         },
             getAllowEmptyParameter(true).ToSingleElementArray(),
             "{ " +
             StringTools.ConcatenateWithDelimiter(
                 " ",
                 "var c = new DatePicker( v ) { ConstrainToSqlSmallDateTimeRange = constrainToSqlSmallDateTimeRange };",
                 "if( minDate.HasValue ) c.MinDate = minDate.Value;",
                 "if( maxDate.HasValue ) c.MaxDate = maxDate.Value;",
                 "return c;") + " }",
             "control.ValidateAndGetNullablePostBackDate( postBackValues, validator, new ValidationErrorHandler( subject ), allowEmpty )",
             "");
     }
     if (field.TypeIs(typeof(DateTime)))
     {
         writeFormItemGetters(
             writer,
             field,
             "DatePicker",
             "Date",
             "System.DateTime?",
             "null",
             new CSharpParameter[0],
             new CSharpParameter[0],
             new[]
         {
             new CSharpParameter("System.DateTime?", "minDate", "null"), new CSharpParameter("System.DateTime?", "maxDate", "null"),
             new CSharpParameter("bool", "constrainToSqlSmallDateTimeRange", "true")
         },
             new CSharpParameter[0],
             "{ " +
             StringTools.ConcatenateWithDelimiter(
                 " ",
                 "var c = new DatePicker( v ) { ConstrainToSqlSmallDateTimeRange = constrainToSqlSmallDateTimeRange };",
                 "if( minDate.HasValue ) c.MinDate = minDate.Value;",
                 "if( maxDate.HasValue ) c.MaxDate = maxDate.Value;",
                 "return c;") + " }",
             "control.ValidateAndGetPostBackDate( postBackValues, validator, new ValidationErrorHandler( subject ) )",
             "");
     }
 }
 private static void writeBoolFormItemGetters(TextWriter writer, ModificationField field)
 {
     if (field.TypeIs(typeof(bool)))
     {
         writeCheckBoxFormItemGetters(writer, field, "bool");
         writeNumberAsSelectListFormItemGetters(writer, field);
     }
     if (field.TypeIs(typeof(bool?)))
     {
         writeNumberAsSelectListFormItemGetters(writer, field);
     }
 }
示例#6
0
        private static string getNumberControlValueStepStatements(ModificationField field)
        {
            if ((!field.TypeIs(typeof(decimal)) && !field.TypeIs(typeof(decimal? ))) || !field.NumericScale.HasValue)
            {
                return("");
            }
            var minStep = field.NumericScale.Value == 0
                                              ? "1"
                                              : ".{0}1m".FormatWith(
                string.Concat(Enumerable.Repeat('0', Math.Min(field.NumericScale.Value, (short)28 /* max scale for decimal */) - 1)));

            return(StringTools.ConcatenateWithDelimiter(
                       Environment.NewLine,
                       "if( !valueStep.HasValue ) valueStep = {0};".FormatWith(minStep),
                       "else if( valueStep.Value % {0} != 0 ) throw new System.ApplicationException( \"The specified step is not a multiple of the field’s minimum step.\" );"
                       .FormatWith(minStep)));
        }
        private static void writeGenericGetter(
            TextWriter writer, ModificationField field, bool includeValueParams, bool?includeValidationMethodReturnValue, string body)
        {
            CodeGenerationStatics.AddSummaryDocComment(writer, getFormItemGetterSummary(field, "", new string[0]));
            CodeGenerationStatics.AddParamDocComment(writer, "additionalValidationMethod", "Passes the labelAndSubject and a validator to the function.");
            CodeGenerationStatics.AddParamDocComment(writer, "validationList", validationListParamDocComment);

            var parameters = new List <CSharpParameter>();

            if (includeValueParams)
            {
                parameters.Add(new CSharpParameter("bool", "useValueParameter"));
            }
            parameters.Add(
                new CSharpParameter("System.Func<" + (includeValueParams ? field.NullableTypeName : field.TypeName) + ",string,ControlType>", "controlGetter"));
            if (includeValidationMethodReturnValue.HasValue)
            {
                parameters.Add(
                    includeValidationMethodReturnValue.Value
                                                ? new CSharpParameter("System.Func<ControlType,PostBackValueDictionary,string,Validator," + field.TypeName + ">", "validationMethod")
                                                : new CSharpParameter("System.Action<ControlType,PostBackValueDictionary,string,Validator>", "validationMethod"));
            }
            parameters.Add(new CSharpParameter("string", "labelAndSubject", "\"" + getDefaultLabelAndSubject(field) + "\""));
            parameters.Add(new CSharpParameter("FormItemLabel", "labelOverride", "null"));
            if (includeValueParams)
            {
                parameters.Add(new CSharpParameter(field.NullableTypeName, "value", field.TypeIs(typeof(string)) ? "\"\"" : "null"));
            }
            parameters.Add(new CSharpParameter("int?", "cellSpan", "null"));
            parameters.Add(new CSharpParameter("TextAlignment", "textAlignment", "TextAlignment.NotSpecified"));
            if (includeValidationMethodReturnValue.HasValue)
            {
                parameters.Add(new CSharpParameter("System.Func<bool>", "validationPredicate", "null"));
                parameters.Add(new CSharpParameter("System.Action", "validationErrorNotifier", "null"));
                parameters.Add(new CSharpParameter("System.Action<string,Validator>", "additionalValidationMethod", "null"));
                parameters.Add(new CSharpParameter("ValidationList", "validationList", "null"));
            }

            writer.WriteLine(
                "public FormItem<ControlType> " + StandardLibraryMethods.GetCSharpIdentifierSimple("Get" + field.PascalCasedName + "FormItem") + "<ControlType>( " +
                parameters.Select(i => i.MethodSignatureDeclaration).GetCommaDelimitedStringFromCollection() + " ) where ControlType: Control {");
            writer.WriteLine(body);
            writer.WriteLine("}");
        }
        private static void writeGenericGetter(
            TextWriter writer, ModificationField field, bool includeValueParams, bool? includeValidationMethodReturnValue, string body)
        {
            CodeGenerationStatics.AddSummaryDocComment( writer, getFormItemGetterSummary( field, "", new string[ 0 ] ) );
            CodeGenerationStatics.AddParamDocComment( writer, "additionalValidationMethod", "Passes the labelAndSubject and a validator to the function." );
            CodeGenerationStatics.AddParamDocComment( writer, "validationList", validationListParamDocComment );

            var parameters = new List<CSharpParameter>();
            if( includeValueParams )
                parameters.Add( new CSharpParameter( "bool", "useValueParameter" ) );
            parameters.Add(
                new CSharpParameter( "System.Func<" + ( includeValueParams ? field.NullableTypeName : field.TypeName ) + ",string,ControlType>", "controlGetter" ) );
            if( includeValidationMethodReturnValue.HasValue ) {
                parameters.Add(
                    includeValidationMethodReturnValue.Value
                        ? new CSharpParameter( "System.Func<ControlType,PostBackValueDictionary,string,Validator," + field.TypeName + ">", "validationMethod" )
                        : new CSharpParameter( "System.Action<ControlType,PostBackValueDictionary,string,Validator>", "validationMethod" ) );
            }
            parameters.Add( new CSharpParameter( "string", "labelAndSubject", "\"" + getDefaultLabelAndSubject( field ) + "\"" ) );
            parameters.Add( new CSharpParameter( "FormItemLabel", "labelOverride", "null" ) );
            if( includeValueParams )
                parameters.Add( new CSharpParameter( field.NullableTypeName, "value", field.TypeIs( typeof( string ) ) ? "\"\"" : "null" ) );
            parameters.Add( new CSharpParameter( "int?", "cellSpan", "null" ) );
            parameters.Add( new CSharpParameter( "TextAlignment", "textAlignment", "TextAlignment.NotSpecified" ) );
            if( includeValidationMethodReturnValue.HasValue ) {
                parameters.Add( new CSharpParameter( "System.Func<bool>", "validationPredicate", "null" ) );
                parameters.Add( new CSharpParameter( "System.Action", "validationErrorNotifier", "null" ) );
                parameters.Add( new CSharpParameter( "System.Action<string,Validator>", "additionalValidationMethod", "null" ) );
                parameters.Add( new CSharpParameter( "ValidationList", "validationList", "null" ) );
            }

            writer.WriteLine(
                "public FormItem<ControlType> " + EwlStatics.GetCSharpIdentifierSimple( "Get" + field.PascalCasedName + "FormItem" ) + "<ControlType>( " +
                parameters.Select( i => i.MethodSignatureDeclaration ).GetCommaDelimitedStringFromCollection() + " ) where ControlType: Control {" );
            writer.WriteLine( body );
            writer.WriteLine( "}" );
        }
示例#9
0
        private static void writeDateAndTimeFormItemGetters(TextWriter writer, ModificationField field)
        {
            if (field.TypeIs(typeof(DateTime)))
            {
                writeFormItemGetter(
                    writer,
                    field,
                    "DateControl",
                    Enumerable.Empty <CSharpParameter>(),
                    false,
                    new CSharpParameter("DateControlSetup", "controlSetup", defaultValue: "null").ToCollection(),
                    "SpecifiedValue<{0}>".FormatWith(field.NullableTypeName),
                    new CSharpParameter("LocalDate?", "minValue", "null").ToCollection().Append(new CSharpParameter("LocalDate?", "maxValue", "null")),
                    true,
                    dv =>
                    "{0}.ToDateControl( setup: controlSetup, value: value, minValue: minValue, maxValue: maxValue, additionalValidationMethod: additionalValidationMethod ).ToFormItem( setup: formItemSetup, label: label )"
                    .FormatWith(dv));
            }
            if (field.TypeIs(typeof(DateTime? )))
            {
                writeFormItemGetter(
                    writer,
                    field,
                    "DateControl",
                    Enumerable.Empty <CSharpParameter>(),
                    false,
                    new CSharpParameter("DateControlSetup", "controlSetup", defaultValue: "null").ToCollection(),
                    "SpecifiedValue<{0}>".FormatWith(field.NullableTypeName),
                    getAllowEmptyParameter(true)
                    .ToCollection()
                    .Append(new CSharpParameter("LocalDate?", "minValue", "null"))
                    .Append(new CSharpParameter("LocalDate?", "maxValue", "null")),
                    true,
                    dv =>
                    "{0}.ToDateControl( setup: controlSetup, value: value, allowEmpty: allowEmpty, minValue: minValue, maxValue: maxValue, additionalValidationMethod: additionalValidationMethod ).ToFormItem( setup: formItemSetup, label: label )"
                    .FormatWith(dv));
            }

            if (field.TypeIs(typeof(DateTime)))
            {
                writeFormItemGetter(
                    writer,
                    field,
                    "DateAndTimeControl",
                    Enumerable.Empty <CSharpParameter>(),
                    false,
                    new CSharpParameter("DateAndTimeControlSetup", "controlSetup", defaultValue: "null").ToCollection(),
                    "SpecifiedValue<{0}>".FormatWith(field.NullableTypeName),
                    new CSharpParameter("LocalDate?", "minValue", "null").ToCollection().Append(new CSharpParameter("LocalDate?", "maxValue", "null")),
                    true,
                    dv =>
                    "{0}.ToDateAndTimeControl( setup: controlSetup, value: value, minValue: minValue, maxValue: maxValue, additionalValidationMethod: additionalValidationMethod ).ToFormItem( setup: formItemSetup, label: label )"
                    .FormatWith(dv));
            }
            if (field.TypeIs(typeof(DateTime? )))
            {
                writeFormItemGetter(
                    writer,
                    field,
                    "DateAndTimeControl",
                    Enumerable.Empty <CSharpParameter>(),
                    false,
                    new CSharpParameter("DateAndTimeControlSetup", "controlSetup", defaultValue: "null").ToCollection(),
                    "SpecifiedValue<{0}>".FormatWith(field.NullableTypeName),
                    getAllowEmptyParameter(true)
                    .ToCollection()
                    .Append(new CSharpParameter("LocalDate?", "minValue", "null"))
                    .Append(new CSharpParameter("LocalDate?", "maxValue", "null")),
                    true,
                    dv =>
                    "{0}.ToDateAndTimeControl( setup: controlSetup, value: value, allowEmpty: allowEmpty, minValue: minValue, maxValue: maxValue, additionalValidationMethod: additionalValidationMethod ).ToFormItem( setup: formItemSetup, label: label )"
                    .FormatWith(dv));
            }

            if (field.TypeIs(typeof(int)) || field.TypeIs(typeof(int?)) || field.TypeIs(typeof(decimal)) || field.TypeIs(typeof(decimal? )))
            {
                writeFormItemGetter(
                    writer,
                    field,
                    "DurationControl",
                    Enumerable.Empty <CSharpParameter>(),
                    false,
                    new CSharpParameter("DurationControlSetup", "controlSetup", defaultValue: "null").ToCollection(),
                    "SpecifiedValue<{0}>".FormatWith(field.NullableTypeName),
                    field.TypeName == field.NullableTypeName ? getAllowEmptyParameter(true).ToCollection() : Enumerable.Empty <CSharpParameter>(),
                    true,
                    dv => field.TypeName == field.NullableTypeName
                                                      ? "{0}.ToDurationControl( setup: controlSetup, value: value, allowEmpty: allowEmpty, additionalValidationMethod: additionalValidationMethod ).ToFormItem( setup: formItemSetup, label: label )"
                    .FormatWith(dv)
                                                      : "{0}.ToDurationControl( setup: controlSetup, value: value, additionalValidationMethod: additionalValidationMethod ).ToFormItem( setup: formItemSetup, label: label )"
                    .FormatWith(dv));
            }
        }
示例#10
0
        private static void writeListFormItemGetters(TextWriter writer, ModificationField field)
        {
            if (field.TypeIs(typeof(bool)) || field.TypeIs(typeof(int)) || field.TypeIs(typeof(long)) || field.TypeIs(typeof(decimal)))
            {
                writeFormItemGetter(
                    writer,
                    field,
                    "RadioList",
                    new CSharpParameter("RadioListSetup<{0}>".FormatWith(field.NullableTypeName), "controlSetup").ToCollection(),
                    false,
                    Enumerable.Empty <CSharpParameter>(),
                    "SpecifiedValue<{0}>".FormatWith(field.NullableTypeName),
                    Enumerable.Empty <CSharpParameter>(),
                    true,
                    dv =>
                    "{0}.ToRadioList( controlSetup, value: value, additionalValidationMethod: additionalValidationMethod ).ToFormItem( setup: formItemSetup, label: label )"
                    .FormatWith(dv));
            }
            if (field.TypeIs(typeof(bool?)) || field.TypeIs(typeof(int?)) || field.TypeIs(typeof(long?)) || field.TypeIs(typeof(string)) ||
                field.TypeIs(typeof(decimal? )))
            {
                writeFormItemGetter(
                    writer,
                    field,
                    "RadioList",
                    new CSharpParameter("RadioListSetup<{0}>".FormatWith(field.NullableTypeName), "controlSetup").ToCollection(),
                    false,
                    new CSharpParameter("string", "defaultValueItemLabel", defaultValue: field.TypeIs(typeof(string)) ? "\"\"" : "\"None\"").ToCollection(),
                    field.TypeIs(typeof(string)) ? field.NullableTypeName : "SpecifiedValue<{0}>".FormatWith(field.NullableTypeName),
                    Enumerable.Empty <CSharpParameter>(),
                    true,
                    dv =>
                    "{0}.ToRadioList( controlSetup, defaultValueItemLabel: defaultValueItemLabel, value: value, additionalValidationMethod: additionalValidationMethod ).ToFormItem( setup: formItemSetup, label: label )"
                    .FormatWith(dv));
            }

            if (field.TypeIs(typeof(bool)) || field.TypeIs(typeof(int)) || field.TypeIs(typeof(long)) || field.TypeIs(typeof(decimal)))
            {
                writeFormItemGetter(
                    writer,
                    field,
                    "DropDown",
                    new CSharpParameter("DropDownSetup<{0}>".FormatWith(field.NullableTypeName), "controlSetup").ToCollection(),
                    false,
                    Enumerable.Empty <CSharpParameter>(),
                    "SpecifiedValue<{0}>".FormatWith(field.NullableTypeName),
                    Enumerable.Empty <CSharpParameter>(),
                    true,
                    dv =>
                    "{0}.ToDropDown( controlSetup, value: value, additionalValidationMethod: additionalValidationMethod ).ToFormItem( setup: formItemSetup, label: label )"
                    .FormatWith(dv));
            }
            if (field.TypeIs(typeof(bool?)) || field.TypeIs(typeof(int?)) || field.TypeIs(typeof(long?)) || field.TypeIs(typeof(string)) ||
                field.TypeIs(typeof(decimal? )))
            {
                writeFormItemGetter(
                    writer,
                    field,
                    "DropDown",
                    new CSharpParameter("DropDownSetup<{0}>".FormatWith(field.NullableTypeName), "controlSetup").ToCollection()
                    .Concat(
                        field.TypeIs(typeof(string))
                                                                ? Enumerable.Empty <CSharpParameter>()
                                                                : new CSharpParameter("string", "defaultValueItemLabel").ToCollection()),
                    false,
                    (field.TypeIs(typeof(string))
                                                  ? new CSharpParameter("string", "defaultValueItemLabel", defaultValue: "\"\"").ToCollection()
                                                  : Enumerable.Empty <CSharpParameter>()).Append(
                        new CSharpParameter("bool", "placeholderIsValid", field.TypeIs(typeof(string)) ? "false" : "true")),
                    field.TypeIs(typeof(string)) ? field.NullableTypeName : "SpecifiedValue<{0}>".FormatWith(field.NullableTypeName),
                    Enumerable.Empty <CSharpParameter>(),
                    true,
                    dv =>
                    "{0}.ToDropDown( controlSetup, {1}defaultValueItemLabel, placeholderIsValid: placeholderIsValid, value: value, additionalValidationMethod: additionalValidationMethod ).ToFormItem( setup: formItemSetup, label: label )"
                    .FormatWith(dv, field.TypeIs(typeof(string)) ? "defaultValueItemLabel: " : ""));
            }

            if (field.EnumerableElementTypeName.Any())
            {
                writeFormItemGetter(
                    writer,
                    field,
                    "CheckboxList",
                    new CSharpParameter("CheckboxListSetup<{0}>".FormatWith(field.EnumerableElementTypeName), "checkboxListSetup").ToCollection(),
                    false,
                    Enumerable.Empty <CSharpParameter>(),
                    field.TypeName,
                    Enumerable.Empty <CSharpParameter>(),
                    true,
                    dv =>
                    "{0}.ToCheckboxList( checkboxListSetup, value: value, additionalValidationMethod: additionalValidationMethod ).ToFormItem( setup: formItemSetup, label: label )"
                    .FormatWith(dv));
            }
        }
示例#11
0
        private static void writeCheckboxFormItemGetters(TextWriter writer, ModificationField field)
        {
            if (!field.TypeIs(typeof(bool)) && !field.TypeIs(typeof(bool?)) && !field.TypeIs(typeof(decimal)) && !field.TypeIs(typeof(decimal? )))
            {
                return;
            }

            var preFormItemStatements = field.TypeName == field.NullableTypeName
                                                            ? "var nonNullableValue = new DataValue<{0}>();".FormatWith(field.TypeIs(typeof(decimal? )) ? "decimal" : "bool")
                                            : "";

            string getDataValueExpression(string dv) => field.TypeName == field.NullableTypeName ? "nonNullableValue" : dv;
            string getValueExpression(string dv) => field.TypeName == field.NullableTypeName ? "value ?? {0}.Value.Value".FormatWith(dv) : "value";

            string getAdditionalValidationMethodExpression(string dv) =>
            field.TypeName == field.NullableTypeName
                                        ? "validator => {{ {0}.Value = nonNullableValue.Value; additionalValidationMethod?.Invoke( validator ); }}".FormatWith(dv)
                                        : "additionalValidationMethod";

            // checkboxes
            writeFormItemGetter(
                writer,
                field,
                "Checkbox",
                new CSharpParameter[0],
                true,
                new[] { new CSharpParameter("CheckboxSetup", "checkboxSetup", "null") },
                field.NullableTypeName,
                new CSharpParameter[0],
                true,
                dv =>
                "{0}.ToCheckbox( label, setup: checkboxSetup, value: {1}, additionalValidationMethod: {2} ).ToFormItem( setup: formItemSetup, label: formItemLabel )"
                .FormatWith(getDataValueExpression(dv), getValueExpression(dv), getAdditionalValidationMethodExpression(dv)),
                preFormItemStatements: preFormItemStatements);
            writeFormItemGetter(
                writer,
                field,
                "FlowCheckbox",
                new CSharpParameter[0],
                true,
                new[] { new CSharpParameter("FlowCheckboxSetup", "checkboxSetup", "null") },
                field.NullableTypeName,
                new CSharpParameter[0],
                true,
                dv =>
                "{0}.ToFlowCheckbox( label, setup: checkboxSetup, value: {1}, additionalValidationMethod: {2} ).ToFormItem( setup: formItemSetup, label: formItemLabel )"
                .FormatWith(getDataValueExpression(dv), getValueExpression(dv), getAdditionalValidationMethodExpression(dv)),
                preFormItemStatements: preFormItemStatements);

            // radio buttons
            writeFormItemGetter(
                writer,
                field,
                "RadioButton",
                new CSharpParameter("RadioButtonGroup", "group").ToCollection(),
                true,
                new[] { new CSharpParameter("RadioButtonSetup", "radioButtonSetup", "null") },
                field.NullableTypeName,
                new CSharpParameter[0],
                true,
                dv =>
                "{0}.ToRadioButton( group, label, setup: radioButtonSetup, value: {1}, additionalValidationMethod: {2} ).ToFormItem( setup: formItemSetup, label: formItemLabel )"
                .FormatWith(getDataValueExpression(dv), getValueExpression(dv), getAdditionalValidationMethodExpression(dv)),
                preFormItemStatements: preFormItemStatements);
            writeFormItemGetter(
                writer,
                field,
                "FlowRadioButton",
                new CSharpParameter("RadioButtonGroup", "group").ToCollection(),
                true,
                new[] { new CSharpParameter("FlowRadioButtonSetup", "radioButtonSetup", "null") },
                field.NullableTypeName,
                new CSharpParameter[0],
                true,
                dv =>
                "{0}.ToFlowRadioButton( group, label, setup: radioButtonSetup, value: {1}, additionalValidationMethod: {2} ).ToFormItem( setup: formItemSetup, label: formItemLabel )"
                .FormatWith(getDataValueExpression(dv), getValueExpression(dv), getAdditionalValidationMethodExpression(dv)),
                preFormItemStatements: preFormItemStatements);
        }
示例#12
0
        private static void writeTextFormItemGetters(TextWriter writer, ModificationField field)
        {
            if (field.TypeIs(typeof(string)))
            {
                writeFormItemGetter(
                    writer,
                    field,
                    "TextControl",
                    getAllowEmptyParameter(false).ToCollection(),
                    false,
                    new CSharpParameter("TextControlSetup", "controlSetup", defaultValue: "null").ToCollection(),
                    "string",
                    Enumerable.Empty <CSharpParameter>(),
                    true,
                    dv =>
                    "{0}.ToTextControl( allowEmpty, setup: controlSetup, value: value, maxLength: {1}, additionalValidationMethod: additionalValidationMethod ).ToFormItem( setup: formItemSetup, label: label )"
                    .FormatWith(dv, field.Size?.ToString() ?? "null"));
                writeFormItemGetter(
                    writer,
                    field,
                    "EmailAddressControl",
                    getAllowEmptyParameter(false).ToCollection(),
                    false,
                    new CSharpParameter("EmailAddressControlSetup", "controlSetup", defaultValue: "null").ToCollection(),
                    "string",
                    Enumerable.Empty <CSharpParameter>(),
                    true,
                    dv =>
                    "{0}.ToEmailAddressControl( allowEmpty, setup: controlSetup, value: value, maxLength: {1}, additionalValidationMethod: additionalValidationMethod ).ToFormItem( setup: formItemSetup, label: label )"
                    .FormatWith(dv, field.Size?.ToString() ?? "null"));
                writeFormItemGetter(
                    writer,
                    field,
                    "TelephoneNumberControl",
                    getAllowEmptyParameter(false).ToCollection(),
                    false,
                    new CSharpParameter("TelephoneNumberControlSetup", "controlSetup", defaultValue: "null").ToCollection(),
                    "string",
                    Enumerable.Empty <CSharpParameter>(),
                    true,
                    dv =>
                    "{0}.ToTelephoneNumberControl( allowEmpty, setup: controlSetup, value: value, maxLength: {1}, additionalValidationMethod: additionalValidationMethod ).ToFormItem( setup: formItemSetup, label: label )"
                    .FormatWith(dv, field.Size?.ToString() ?? "null"));
                writeFormItemGetter(
                    writer,
                    field,
                    "UrlControl",
                    getAllowEmptyParameter(false).ToCollection(),
                    false,
                    new CSharpParameter("UrlControlSetup", "controlSetup", defaultValue: "null").ToCollection(),
                    "string",
                    Enumerable.Empty <CSharpParameter>(),
                    true,
                    dv =>
                    "{0}.ToUrlControl( allowEmpty, setup: controlSetup, value: value, maxLength: {1}, additionalValidationMethod: additionalValidationMethod ).ToFormItem( setup: formItemSetup, label: label )"
                    .FormatWith(dv, field.Size?.ToString() ?? "null"));
            }

            if (field.TypeIs(typeof(string)))
            {
                writeFormItemGetter(
                    writer,
                    field,
                    "NumericTextControl",
                    getAllowEmptyParameter(false).ToCollection(),
                    false,
                    new CSharpParameter("NumericTextControlSetup", "controlSetup", defaultValue: "null").ToCollection(),
                    "string",
                    new CSharpParameter("int?", "minLength", defaultValue: "null").ToCollection(),
                    true,
                    dv =>
                    "{0}.ToNumericTextControl( allowEmpty, setup: controlSetup, value: value, minLength: minLength, maxLength: {1}, additionalValidationMethod: additionalValidationMethod ).ToFormItem( setup: formItemSetup, label: label )"
                    .FormatWith(dv, field.Size?.ToString() ?? "null"));
            }
            if (field.TypeIs(typeof(int)) || field.TypeIs(typeof(long)))
            {
                writeFormItemGetter(
                    writer,
                    field,
                    "TextControl",
                    Enumerable.Empty <CSharpParameter>(),
                    false,
                    new CSharpParameter("NumericTextControlSetup", "controlSetup", defaultValue: "null").ToCollection(),
                    "SpecifiedValue<{0}>".FormatWith(field.NullableTypeName),
                    new CSharpParameter(field.NullableTypeName, "minValue", "null").ToCollection()
                    .Append(new CSharpParameter(field.NullableTypeName, "maxValue", "null")),
                    true,
                    dv =>
                    "{0}.ToTextControl( setup: controlSetup, value: value, minValue: minValue, maxValue: maxValue, additionalValidationMethod: additionalValidationMethod ).ToFormItem( setup: formItemSetup, label: label )"
                    .FormatWith(dv));
            }
            if (field.TypeIs(typeof(int?)) || field.TypeIs(typeof(long?)))
            {
                writeFormItemGetter(
                    writer,
                    field,
                    "TextControl",
                    Enumerable.Empty <CSharpParameter>(),
                    false,
                    new CSharpParameter("NumericTextControlSetup", "controlSetup", defaultValue: "null").ToCollection(),
                    "SpecifiedValue<{0}>".FormatWith(field.NullableTypeName),
                    getAllowEmptyParameter(true)
                    .ToCollection()
                    .Append(new CSharpParameter(field.NullableTypeName, "minValue", "null"))
                    .Append(new CSharpParameter(field.NullableTypeName, "maxValue", "null")),
                    true,
                    dv =>
                    "{0}.ToTextControl( setup: controlSetup, value: value, allowEmpty: allowEmpty, minValue: minValue, maxValue: maxValue, additionalValidationMethod: additionalValidationMethod ).ToFormItem( setup: formItemSetup, label: label )"
                    .FormatWith(dv));
            }

            if (field.TypeIs(typeof(string)))
            {
                writeFormItemGetter(
                    writer,
                    field,
                    "Html",
                    getAllowEmptyParameter(false).ToCollection(),
                    false,
                    new CSharpParameter("WysiwygHtmlEditorSetup", "editorSetup", "null").ToCollection(),
                    "string",
                    new CSharpParameter[0],
                    true,
                    dv =>
                    "{0}.ToHtmlEditor( allowEmpty, setup: editorSetup, value: value, maxLength: {1}, additionalValidationMethod: additionalValidationMethod ).ToFormItem( setup: formItemSetup, label: label )"
                    .FormatWith(dv, field.Size?.ToString() ?? "null"),
                    additionalSummarySentences: new[]
                {
                    "WARNING: Do not use this form-item getter unless you know exactly what you're doing.",
                    "If you want to store HTML, it is almost always better to use an HTML block instead of just a string field.",
                    "HTML blocks have special handling for intra-site URIs and may include additional features in the future.",
                    "They also cause all of your HTML to be stored in one place, which is usually a good practice."
                });
            }
        }
示例#13
0
        private static void writeNumericFormItemGetters(TextWriter writer, ModificationField field)
        {
            if (field.TypeIs(typeof(int)) || field.TypeIs(typeof(long)) || field.TypeIs(typeof(short)) || field.TypeIs(typeof(byte)) ||
                field.TypeIs(typeof(decimal)))
            {
                writeFormItemGetter(
                    writer,
                    field,
                    "NumberControl",
                    Enumerable.Empty <CSharpParameter>(),
                    false,
                    new CSharpParameter("NumberControlSetup", "controlSetup", defaultValue: "null").ToCollection(),
                    "SpecifiedValue<{0}>".FormatWith(field.NullableTypeName),
                    new CSharpParameter(field.NullableTypeName, "minValue", "null").ToCollection()
                    .Append(new CSharpParameter(field.NullableTypeName, "maxValue", "null"))
                    .Append(new CSharpParameter(field.NullableTypeName, "valueStep", "null")),
                    true,
                    dv =>
                    "{0}.ToNumberControl( setup: controlSetup, value: value, minValue: minValue, maxValue: maxValue, valueStep: valueStep, additionalValidationMethod: additionalValidationMethod ).ToFormItem( setup: formItemSetup, label: label )"
                    .FormatWith(dv),
                    preFormItemStatements: getNumberControlValueStepStatements(field));
            }
            if (field.TypeIs(typeof(int?)) || field.TypeIs(typeof(long?)) || field.TypeIs(typeof(short?)) || field.TypeIs(typeof(byte?)) ||
                field.TypeIs(typeof(decimal? )))
            {
                writeFormItemGetter(
                    writer,
                    field,
                    "NumberControl",
                    Enumerable.Empty <CSharpParameter>(),
                    false,
                    new CSharpParameter("NumberControlSetup", "controlSetup", defaultValue: "null").ToCollection(),
                    "SpecifiedValue<{0}>".FormatWith(field.NullableTypeName),
                    getAllowEmptyParameter(true)
                    .ToCollection()
                    .Append(new CSharpParameter(field.NullableTypeName, "minValue", "null"))
                    .Append(new CSharpParameter(field.NullableTypeName, "maxValue", "null"))
                    .Append(new CSharpParameter(field.NullableTypeName, "valueStep", "null")),
                    true,
                    dv =>
                    "{0}.ToNumberControl( setup: controlSetup, value: value, allowEmpty: allowEmpty, minValue: minValue, maxValue: maxValue, valueStep: valueStep, additionalValidationMethod: additionalValidationMethod ).ToFormItem( setup: formItemSetup, label: label )"
                    .FormatWith(dv),
                    preFormItemStatements: getNumberControlValueStepStatements(field));
            }

            if (field.TypeIs(typeof(int)) || field.TypeIs(typeof(long)) || field.TypeIs(typeof(short)) || field.TypeIs(typeof(byte)) ||
                field.TypeIs(typeof(decimal)))
            {
                writeFormItemGetter(
                    writer,
                    field,
                    "ImpreciseNumberControl",
                    new CSharpParameter(field.TypeName, "minValue").ToCollection().Append(new CSharpParameter(field.TypeName, "maxValue")),
                    false,
                    new CSharpParameter("ImpreciseNumberControlSetup", "controlSetup", defaultValue: "null").ToCollection(),
                    field.NullableTypeName,
                    new CSharpParameter(field.NullableTypeName, "valueStep", "null").ToCollection(),
                    true,
                    dv =>
                    "{0}.ToImpreciseNumberControl( minValue, maxValue, setup: controlSetup, value: value, valueStep: valueStep, additionalValidationMethod: additionalValidationMethod ).ToFormItem( setup: formItemSetup, label: label )"
                    .FormatWith(dv),
                    preFormItemStatements: getNumberControlValueStepStatements(field));
            }

            if (field.TypeIs(typeof(int)))
            {
                writeHtmlAndFileFormItemGetters(writer, field, "int?");
            }
            if (field.TypeIs(typeof(int?)))
            {
                writeHtmlAndFileFormItemGetters(writer, field, "int?");
            }

            if (field.TypeIs(typeof(decimal)))
            {
                writeHtmlAndFileFormItemGetters(writer, field, "decimal?");
            }
            if (field.TypeIs(typeof(decimal? )))
            {
                writeHtmlAndFileFormItemGetters(writer, field, "decimal?");
            }
        }
 private static void writeGuidFormItemGetters( TextWriter writer, ModificationField field )
 {
     if( !field.TypeIs( typeof( Guid ) ) )
         return;
     writeNumberAsSelectListFormItemGetters( writer, field );
 }
 private static void writeDateFormItemGetters( TextWriter writer, ModificationField field )
 {
     if( field.TypeIs( typeof( DateTime? ) ) ) {
         writeFormItemGetters(
             writer,
             field,
             "DatePicker",
             "Date",
             "System.DateTime?",
             "null",
             new CSharpParameter[ 0 ],
             new CSharpParameter[ 0 ],
             new[]
                 {
                     new CSharpParameter( "System.DateTime?", "minDate", "null" ), new CSharpParameter( "System.DateTime?", "maxDate", "null" ),
                     new CSharpParameter( "bool", "constrainToSqlSmallDateTimeRange", "true" ), new CSharpParameter( "PostBack", "postBack", "null" )
                 },
             getAllowEmptyParameter( true ).ToSingleElementArray(),
             "{ " +
             StringTools.ConcatenateWithDelimiter(
                 " ",
                 "var c = new DatePicker( v, postBack: postBack ) { ConstrainToSqlSmallDateTimeRange = constrainToSqlSmallDateTimeRange };",
                 "if( minDate.HasValue ) c.MinDate = minDate.Value;",
                 "if( maxDate.HasValue ) c.MaxDate = maxDate.Value;",
                 "return c;" ) + " }",
             "control.ValidateAndGetNullablePostBackDate( postBackValues, validator, new ValidationErrorHandler( subject ), allowEmpty )",
             "" );
     }
     if( field.TypeIs( typeof( DateTime ) ) ) {
         writeFormItemGetters(
             writer,
             field,
             "DatePicker",
             "Date",
             "System.DateTime?",
             "null",
             new CSharpParameter[ 0 ],
             new CSharpParameter[ 0 ],
             new[]
                 {
                     new CSharpParameter( "System.DateTime?", "minDate", "null" ), new CSharpParameter( "System.DateTime?", "maxDate", "null" ),
                     new CSharpParameter( "bool", "constrainToSqlSmallDateTimeRange", "true" ), new CSharpParameter( "PostBack", "postBack", "null" )
                 },
             new CSharpParameter[ 0 ],
             "{ " +
             StringTools.ConcatenateWithDelimiter(
                 " ",
                 "var c = new DatePicker( v, postBack: postBack ) { ConstrainToSqlSmallDateTimeRange = constrainToSqlSmallDateTimeRange };",
                 "if( minDate.HasValue ) c.MinDate = minDate.Value;",
                 "if( maxDate.HasValue ) c.MaxDate = maxDate.Value;",
                 "return c;" ) + " }",
             "control.ValidateAndGetPostBackDate( postBackValues, validator, new ValidationErrorHandler( subject ) )",
             "" );
     }
 }
        private static void writeStringFormItemGetters(TextWriter writer, ModificationField field)
        {
            if (!field.TypeIs(typeof(string)))
            {
                return;
            }

            writeFormItemGetters(
                writer,
                field,
                "EwfTextBox",
                "Text",
                "string",
                "\"\"",
                new CSharpParameter[0],
                getAllowEmptyParameter(false).ToSingleElementArray(),
                new[]
            {
                new CSharpParameter("int", "textBoxRows", "1"), new CSharpParameter("bool", "masksCharacters", "false"),
                new CSharpParameter("bool", "readOnly", "false"), new CSharpParameter("bool?", "suggestSpellCheck", "null"),
                new CSharpParameter("PostBack", "postBack", "null"), new CSharpParameter("bool", "autoPostBack", "false")
            },
                new CSharpParameter[0],
                "new EwfTextBox( v, rows: textBoxRows, masksCharacters: masksCharacters, " + (field.Size.HasValue ? "maxLength: " + field.Size.Value + ", " : "") +
                "readOnly: readOnly, suggestSpellCheck: suggestSpellCheck, postBack: postBack, autoPostBack: autoPostBack )",
                "validator.GetString( new ValidationErrorHandler( subject ), control.GetPostBackValue( postBackValues ), allowEmpty" +
                (field.Size.HasValue ? ", " + field.Size.Value : "") + " )",
                "");
            writeFormItemGetters(
                writer,
                field,
                "EwfTextBox",
                "EmailAddress",
                "string",
                "\"\"",
                new CSharpParameter[0],
                getAllowEmptyParameter(false).ToSingleElementArray(),
                new[]
            {
                new CSharpParameter("bool", "readOnly", "false"), new CSharpParameter("PostBack", "postBack", "null"),
                new CSharpParameter("bool", "autoPostBack", "false")
            },
                new CSharpParameter[0],
                "new EwfTextBox( v" + (field.Size.HasValue ? ", maxLength: " + field.Size.Value : "") +
                ", readOnly: readOnly, postBack: postBack, autoPostBack: autoPostBack )",
                "validator.GetEmailAddress( new ValidationErrorHandler( subject ), control.GetPostBackValue( postBackValues ), allowEmpty" +
                (field.Size.HasValue ? ", maxLength: " + field.Size.Value : "") + " )",
                "");
            writeFormItemGetters(
                writer,
                field,
                "EwfTextBox",
                "PhoneNumber",
                "string",
                "\"\"",
                new CSharpParameter[0],
                getAllowEmptyParameter(false).ToSingleElementArray(),
                new[]
            {
                new CSharpParameter("bool", "readOnly", "false"), new CSharpParameter("PostBack", "postBack", "null"),
                new CSharpParameter("bool", "autoPostBack", "false")
            },
                new[] { new CSharpParameter("bool", "allowExtension", "true"), new CSharpParameter("bool", "allowSurroundingGarbage", "false") },
                "new EwfTextBox( v" + (field.Size.HasValue ? ", maxLength: " + field.Size.Value : "") +
                ", readOnly: readOnly, postBack: postBack, autoPostBack: autoPostBack )",
                "validator.GetPhoneNumber( new ValidationErrorHandler( subject ), control.GetPostBackValue( postBackValues ), allowExtension, allowEmpty, allowSurroundingGarbage )",
                "");
            writeFormItemGetters(
                writer,
                field,
                "EwfTextBox",
                "ZipCode",
                "string",
                "\"\"",
                new CSharpParameter[0],
                getAllowEmptyParameter(false).ToSingleElementArray(),
                new[]
            {
                new CSharpParameter("bool", "readOnly", "false"), new CSharpParameter("PostBack", "postBack", "null"),
                new CSharpParameter("bool", "autoPostBack", "false")
            },
                new CSharpParameter[0],
                "new EwfTextBox( v" + (field.Size.HasValue ? ", maxLength: " + field.Size.Value : "") +
                ", readOnly: readOnly, postBack: postBack, autoPostBack: autoPostBack )",
                "validator.GetZipCode( new ValidationErrorHandler( subject ), control.GetPostBackValue( postBackValues ), allowEmpty ).FullZipCode",
                "");
            writeFormItemGetters(
                writer,
                field,
                "EwfTextBox",
                "Uri",
                "string",
                "\"\"",
                new CSharpParameter[0],
                getAllowEmptyParameter(false).ToSingleElementArray(),
                new[]
            {
                new CSharpParameter("bool", "readOnly", "false"), new CSharpParameter("PostBack", "postBack", "null"),
                new CSharpParameter("bool", "autoPostBack", "false")
            },
                new CSharpParameter[0],
                "new EwfTextBox( v" + (field.Size.HasValue ? ", maxLength: " + field.Size.Value : "") +
                ", readOnly: readOnly, postBack: postBack, autoPostBack: autoPostBack )",
                "validator.GetUrl( new ValidationErrorHandler( subject ), control.GetPostBackValue( postBackValues ), allowEmpty" +
                (field.Size.HasValue ? ", " + field.Size.Value : "") + " )",
                "");
            writeFormItemGetters(
                writer,
                field,
                "SelectList<string>",
                "RadioList",
                "string",
                "\"\"",
                new[] { new CSharpParameter("IEnumerable<SelectListItem<string>>", "items") },
                new CSharpParameter[0],
                new[]
            {
                new CSharpParameter("bool", "useHorizontalLayout", "false"), new CSharpParameter("string", "defaultValueItemLabel", "\"\""),
                new CSharpParameter("bool", "disableSingleButtonDetection", "false"), new CSharpParameter("PostBack", "postBack", "null"),
                new CSharpParameter("bool", "autoPostBack", "false")
            },
                new CSharpParameter[0],
                "SelectList.CreateRadioList( items, v, useHorizontalLayout: useHorizontalLayout, defaultValueItemLabel: defaultValueItemLabel, disableSingleButtonDetection: disableSingleButtonDetection, postBack: postBack, autoPostBack: autoPostBack )",
                "control.ValidateAndGetSelectedItemIdInPostBack( postBackValues, validator )",
                "");
            writeFormItemGetters(
                writer,
                field,
                "SelectList<string>",
                "DropDown",
                "string",
                "\"\"",
                new[] { new CSharpParameter("IEnumerable<SelectListItem<string>>", "items") },
                new CSharpParameter[0],
                new[]
            {
                new CSharpParameter("Unit?", "width", "null"), new CSharpParameter("string", "defaultValueItemLabel", "\"\""),
                new CSharpParameter("bool", "placeholderIsValid", "false"), new CSharpParameter("string", "placeholderText", "\"Please select\""),
                new CSharpParameter("PostBack", "postBack", "null"), new CSharpParameter("bool", "autoPostBack", "false")
            },
                new CSharpParameter[0],
                "SelectList.CreateDropDown( items, v, width: width, defaultValueItemLabel: defaultValueItemLabel, placeholderIsValid: placeholderIsValid, placeholderText: placeholderText, postBack: postBack, autoPostBack: autoPostBack )",
                "control.ValidateAndGetSelectedItemIdInPostBack( postBackValues, validator )",
                "");
            writeFormItemGetters(
                writer,
                field,
                "WysiwygHtmlEditor",
                "Html",
                "string",
                "\"\"",
                new CSharpParameter[0],
                getAllowEmptyParameter(false).ToSingleElementArray(),
                new CSharpParameter("string", "ckEditorConfiguration", "\"\"").ToSingleElementArray(),
                new CSharpParameter[0],
                "new WysiwygHtmlEditor( v, ckEditorConfiguration: ckEditorConfiguration )",
                "validator.GetString( new ValidationErrorHandler( subject ), control.GetPostBackValue( postBackValues ), allowEmpty" +
                (field.Size.HasValue ? ", " + field.Size.Value : "") + " )",
                "",
                additionalSummarySentences:
                new[]
            {
                "WARNING: Do not use this form-item getter unless you know exactly what you're doing.",
                "If you want to store HTML, it is almost always better to use an HTML block instead of just a string field.",
                "HTML blocks have special handling for intra-site URIs and may include additional features in the future.",
                "They also cause all of your HTML to be stored in one place, which is usually a good practice."
            });
        }
        private static void writeNumericFormItemGetters(TextWriter writer, ModificationField field)
        {
            if (field.TypeIs(typeof(int)))
            {
                writeNumberAsTextFormItemGetters(
                    writer,
                    field,
                    "int?",
                    new[] { new CSharpParameter("int", "min", "int.MinValue"), new CSharpParameter("int", "max", "int.MaxValue") },
                    "validator.GetInt( new ValidationErrorHandler( subject ), control.GetPostBackValue( postBackValues ), min, max )");
                writeNumberAsSelectListFormItemGetters(writer, field);
                writeHtmlAndFileFormItemGetters(writer, field, "int?");
                writeFileCollectionFormItemGetters(writer, field, "int");
                writeDurationFormItemGetters(writer, field);
            }
            if (field.TypeIs(typeof(int?)))
            {
                writeNumberAsTextFormItemGetters(
                    writer,
                    field,
                    "int?",
                    new[] { getAllowEmptyParameter(true), new CSharpParameter("int", "min", "int.MinValue"), new CSharpParameter("int", "max", "int.MaxValue") },
                    "validator.GetNullableInt( new ValidationErrorHandler( subject ), control.GetPostBackValue( postBackValues ), allowEmpty, min: min, max: max )");
                writeNumberAsSelectListFormItemGetters(writer, field);
                writeHtmlAndFileFormItemGetters(writer, field, "int?");
            }

            if (field.TypeIs(typeof(short)))
            {
                writeNumberAsTextFormItemGetters(
                    writer,
                    field,
                    "short?",
                    new[] { new CSharpParameter("short", "min", "short.MinValue"), new CSharpParameter("short", "max", "short.MaxValue") },
                    "validator.GetShort( new ValidationErrorHandler( subject ), control.GetPostBackValue( postBackValues ), min, max )");
                writeNumberAsSelectListFormItemGetters(writer, field);
            }
            if (field.TypeIs(typeof(short?)))
            {
                writeNumberAsTextFormItemGetters(
                    writer,
                    field,
                    "short?",
                    new[] { getAllowEmptyParameter(true), new CSharpParameter("short", "min", "short.MinValue"), new CSharpParameter("short", "max", "short.MaxValue") },
                    "validator.GetNullableShort( new ValidationErrorHandler( subject ), control.GetPostBackValue( postBackValues ), allowEmpty, min, max )");
                writeNumberAsSelectListFormItemGetters(writer, field);
            }

            if (field.TypeIs(typeof(byte)))
            {
                writeNumberAsTextFormItemGetters(
                    writer,
                    field,
                    "byte?",
                    new[] { new CSharpParameter("byte", "min", "byte.MinValue"), new CSharpParameter("byte", "max", "byte.MaxValue") },
                    "validator.GetByte( new ValidationErrorHandler( subject ), control.GetPostBackValue( postBackValues ), min, max )");
                writeNumberAsSelectListFormItemGetters(writer, field);
            }
            if (field.TypeIs(typeof(byte?)))
            {
                writeNumberAsTextFormItemGetters(
                    writer,
                    field,
                    "byte?",
                    getAllowEmptyParameter(true).ToSingleElementArray(),
                    "validator.GetNullableByte( new ValidationErrorHandler( subject ), control.GetPostBackValue( postBackValues ), allowEmpty )");
                writeNumberAsSelectListFormItemGetters(writer, field);
            }

            if (field.TypeIs(typeof(decimal)))
            {
                writeNumberAsTextFormItemGetters(
                    writer,
                    field,
                    "decimal?",
                    new[]
                    { new CSharpParameter("decimal", "min", "Validator.SqlDecimalDefaultMin"), new CSharpParameter("decimal", "max", "Validator.SqlDecimalDefaultMax") },
                    "validator.GetDecimal( new ValidationErrorHandler( subject ), control.GetPostBackValue( postBackValues ), min, max )");
                writeNumberAsSelectListFormItemGetters(writer, field);
                writeCheckBoxFormItemGetters(writer, field, "decimal");
                writeHtmlAndFileFormItemGetters(writer, field, "decimal?");
                writeFileCollectionFormItemGetters(writer, field, "decimal");
                writeDurationFormItemGetters(writer, field);
            }
            if (field.TypeIs(typeof(decimal? )))
            {
                writeNumberAsTextFormItemGetters(
                    writer,
                    field,
                    "decimal?",
                    new[]
                {
                    getAllowEmptyParameter(true), new CSharpParameter("decimal", "min", "Validator.SqlDecimalDefaultMin"),
                    new CSharpParameter("decimal", "max", "Validator.SqlDecimalDefaultMax")
                },
                    "validator.GetNullableDecimal( new ValidationErrorHandler( subject ), control.GetPostBackValue( postBackValues ), allowEmpty, min, max )");
                writeNumberAsSelectListFormItemGetters(writer, field);
                writeHtmlAndFileFormItemGetters(writer, field, "decimal?");
            }
        }
        private static void writeNumericFormItemGetters( TextWriter writer, ModificationField field )
        {
            if( field.TypeIs( typeof( int ) ) ) {
                writeNumberAsTextFormItemGetters(
                    writer,
                    field,
                    "int?",
                    new[] { new CSharpParameter( "int", "min", "int.MinValue" ), new CSharpParameter( "int", "max", "int.MaxValue" ) },
                    "validator.GetInt( new ValidationErrorHandler( subject ), control.GetPostBackValue( postBackValues ), min, max )" );
                writeNumberAsSelectListFormItemGetters( writer, field );
                writeHtmlAndFileFormItemGetters( writer, field, "int?" );
                writeFileCollectionFormItemGetters( writer, field, "int" );
                writeDurationFormItemGetters( writer, field );
            }
            if( field.TypeIs( typeof( int? ) ) ) {
                writeNumberAsTextFormItemGetters(
                    writer,
                    field,
                    "int?",
                    new[] { getAllowEmptyParameter( true ), new CSharpParameter( "int", "min", "int.MinValue" ), new CSharpParameter( "int", "max", "int.MaxValue" ) },
                    "validator.GetNullableInt( new ValidationErrorHandler( subject ), control.GetPostBackValue( postBackValues ), allowEmpty, min: min, max: max )" );
                writeNumberAsSelectListFormItemGetters( writer, field );
                writeHtmlAndFileFormItemGetters( writer, field, "int?" );
            }

            if( field.TypeIs( typeof( short ) ) ) {
                writeNumberAsTextFormItemGetters(
                    writer,
                    field,
                    "short?",
                    new[] { new CSharpParameter( "short", "min", "short.MinValue" ), new CSharpParameter( "short", "max", "short.MaxValue" ) },
                    "validator.GetShort( new ValidationErrorHandler( subject ), control.GetPostBackValue( postBackValues ), min, max )" );
                writeNumberAsSelectListFormItemGetters( writer, field );
            }
            if( field.TypeIs( typeof( short? ) ) ) {
                writeNumberAsTextFormItemGetters(
                    writer,
                    field,
                    "short?",
                    new[] { getAllowEmptyParameter( true ), new CSharpParameter( "short", "min", "short.MinValue" ), new CSharpParameter( "short", "max", "short.MaxValue" ) },
                    "validator.GetNullableShort( new ValidationErrorHandler( subject ), control.GetPostBackValue( postBackValues ), allowEmpty, min, max )" );
                writeNumberAsSelectListFormItemGetters( writer, field );
            }

            if( field.TypeIs( typeof( byte ) ) ) {
                writeNumberAsTextFormItemGetters(
                    writer,
                    field,
                    "byte?",
                    new[] { new CSharpParameter( "byte", "min", "byte.MinValue" ), new CSharpParameter( "byte", "max", "byte.MaxValue" ) },
                    "validator.GetByte( new ValidationErrorHandler( subject ), control.GetPostBackValue( postBackValues ), min, max )" );
                writeNumberAsSelectListFormItemGetters( writer, field );
            }
            if( field.TypeIs( typeof( byte? ) ) ) {
                writeNumberAsTextFormItemGetters(
                    writer,
                    field,
                    "byte?",
                    getAllowEmptyParameter( true ).ToSingleElementArray(),
                    "validator.GetNullableByte( new ValidationErrorHandler( subject ), control.GetPostBackValue( postBackValues ), allowEmpty )" );
                writeNumberAsSelectListFormItemGetters( writer, field );
            }

            if( field.TypeIs( typeof( decimal ) ) ) {
                writeNumberAsTextFormItemGetters(
                    writer,
                    field,
                    "decimal?",
                    new[]
                        { new CSharpParameter( "decimal", "min", "Validator.SqlDecimalDefaultMin" ), new CSharpParameter( "decimal", "max", "Validator.SqlDecimalDefaultMax" ) },
                    "validator.GetDecimal( new ValidationErrorHandler( subject ), control.GetPostBackValue( postBackValues ), min, max )" );
                writeNumberAsSelectListFormItemGetters( writer, field );
                writeCheckBoxFormItemGetters( writer, field, "decimal" );
                writeHtmlAndFileFormItemGetters( writer, field, "decimal?" );
                writeFileCollectionFormItemGetters( writer, field, "decimal" );
                writeDurationFormItemGetters( writer, field );
            }
            if( field.TypeIs( typeof( decimal? ) ) ) {
                writeNumberAsTextFormItemGetters(
                    writer,
                    field,
                    "decimal?",
                    new[]
                        {
                            getAllowEmptyParameter( true ), new CSharpParameter( "decimal", "min", "Validator.SqlDecimalDefaultMin" ),
                            new CSharpParameter( "decimal", "max", "Validator.SqlDecimalDefaultMax" )
                        },
                    "validator.GetNullableDecimal( new ValidationErrorHandler( subject ), control.GetPostBackValue( postBackValues ), allowEmpty, min, max )" );
                writeNumberAsSelectListFormItemGetters( writer, field );
                writeHtmlAndFileFormItemGetters( writer, field, "decimal?" );
            }
        }
        private static void writeStringFormItemGetters( TextWriter writer, ModificationField field )
        {
            if( !field.TypeIs( typeof( string ) ) )
                return;

            writeFormItemGetters(
                writer,
                field,
                "EwfTextBox",
                "Text",
                "string",
                "\"\"",
                new CSharpParameter[ 0 ],
                getAllowEmptyParameter( false ).ToSingleElementArray(),
                new[]
                    {
                        new CSharpParameter( "int", "textBoxRows", "1" ), new CSharpParameter( "bool", "masksCharacters", "false" ),
                        new CSharpParameter( "bool", "readOnly", "false" ), new CSharpParameter( "bool?", "suggestSpellCheck", "null" ),
                        new CSharpParameter( "PostBack", "postBack", "null" ), new CSharpParameter( "bool", "autoPostBack", "false" )
                    },
                new CSharpParameter[ 0 ],
                "new EwfTextBox( v, rows: textBoxRows, masksCharacters: masksCharacters, " + ( field.Size.HasValue ? "maxLength: " + field.Size.Value + ", " : "" ) +
                "readOnly: readOnly, suggestSpellCheck: suggestSpellCheck, postBack: postBack, autoPostBack: autoPostBack )",
                "validator.GetString( new ValidationErrorHandler( subject ), control.GetPostBackValue( postBackValues ), allowEmpty" +
                ( field.Size.HasValue ? ", " + field.Size.Value : "" ) + " )",
                "" );
            writeFormItemGetters(
                writer,
                field,
                "EwfTextBox",
                "EmailAddress",
                "string",
                "\"\"",
                new CSharpParameter[ 0 ],
                getAllowEmptyParameter( false ).ToSingleElementArray(),
                new[]
                    {
                        new CSharpParameter( "bool", "readOnly", "false" ), new CSharpParameter( "PostBack", "postBack", "null" ),
                        new CSharpParameter( "bool", "autoPostBack", "false" )
                    },
                new CSharpParameter[ 0 ],
                "new EwfTextBox( v" + ( field.Size.HasValue ? ", maxLength: " + field.Size.Value : "" ) +
                ", readOnly: readOnly, postBack: postBack, autoPostBack: autoPostBack )",
                "validator.GetEmailAddress( new ValidationErrorHandler( subject ), control.GetPostBackValue( postBackValues ), allowEmpty" +
                ( field.Size.HasValue ? ", maxLength: " + field.Size.Value : "" ) + " )",
                "" );
            writeFormItemGetters(
                writer,
                field,
                "EwfTextBox",
                "PhoneNumber",
                "string",
                "\"\"",
                new CSharpParameter[ 0 ],
                getAllowEmptyParameter( false ).ToSingleElementArray(),
                new[]
                    {
                        new CSharpParameter( "bool", "readOnly", "false" ), new CSharpParameter( "PostBack", "postBack", "null" ),
                        new CSharpParameter( "bool", "autoPostBack", "false" )
                    },
                new[] { new CSharpParameter( "bool", "allowExtension", "true" ), new CSharpParameter( "bool", "allowSurroundingGarbage", "false" ) },
                "new EwfTextBox( v" + ( field.Size.HasValue ? ", maxLength: " + field.Size.Value : "" ) +
                ", readOnly: readOnly, postBack: postBack, autoPostBack: autoPostBack )",
                "validator.GetPhoneNumber( new ValidationErrorHandler( subject ), control.GetPostBackValue( postBackValues ), allowExtension, allowEmpty, allowSurroundingGarbage )",
                "" );
            writeFormItemGetters(
                writer,
                field,
                "EwfTextBox",
                "ZipCode",
                "string",
                "\"\"",
                new CSharpParameter[ 0 ],
                getAllowEmptyParameter( false ).ToSingleElementArray(),
                new[]
                    {
                        new CSharpParameter( "bool", "readOnly", "false" ), new CSharpParameter( "PostBack", "postBack", "null" ),
                        new CSharpParameter( "bool", "autoPostBack", "false" )
                    },
                new CSharpParameter[ 0 ],
                "new EwfTextBox( v" + ( field.Size.HasValue ? ", maxLength: " + field.Size.Value : "" ) +
                ", readOnly: readOnly, postBack: postBack, autoPostBack: autoPostBack )",
                "validator.GetZipCode( new ValidationErrorHandler( subject ), control.GetPostBackValue( postBackValues ), allowEmpty ).FullZipCode",
                "" );
            writeFormItemGetters(
                writer,
                field,
                "EwfTextBox",
                "Uri",
                "string",
                "\"\"",
                new CSharpParameter[ 0 ],
                getAllowEmptyParameter( false ).ToSingleElementArray(),
                new[]
                    {
                        new CSharpParameter( "bool", "readOnly", "false" ), new CSharpParameter( "PostBack", "postBack", "null" ),
                        new CSharpParameter( "bool", "autoPostBack", "false" )
                    },
                new CSharpParameter[ 0 ],
                "new EwfTextBox( v" + ( field.Size.HasValue ? ", maxLength: " + field.Size.Value : "" ) +
                ", readOnly: readOnly, postBack: postBack, autoPostBack: autoPostBack )",
                "validator.GetUrl( new ValidationErrorHandler( subject ), control.GetPostBackValue( postBackValues ), allowEmpty" +
                ( field.Size.HasValue ? ", " + field.Size.Value : "" ) + " )",
                "" );
            writeFormItemGetters(
                writer,
                field,
                "SelectList<string>",
                "RadioList",
                "string",
                "\"\"",
                new[] { new CSharpParameter( "IEnumerable<SelectListItem<string>>", "items" ) },
                new CSharpParameter[ 0 ],
                new[]
                    {
                        new CSharpParameter( "bool", "useHorizontalLayout", "false" ), new CSharpParameter( "string", "defaultValueItemLabel", "\"\"" ),
                        new CSharpParameter( "bool", "disableSingleButtonDetection", "false" ), new CSharpParameter( "PostBack", "postBack", "null" ),
                        new CSharpParameter( "bool", "autoPostBack", "false" )
                    },
                new CSharpParameter[ 0 ],
                "SelectList.CreateRadioList( items, v, useHorizontalLayout: useHorizontalLayout, defaultValueItemLabel: defaultValueItemLabel, disableSingleButtonDetection: disableSingleButtonDetection, postBack: postBack, autoPostBack: autoPostBack )",
                "control.ValidateAndGetSelectedItemIdInPostBack( postBackValues, validator )",
                "" );
            writeFormItemGetters(
                writer,
                field,
                "SelectList<string>",
                "DropDown",
                "string",
                "\"\"",
                new[] { new CSharpParameter( "IEnumerable<SelectListItem<string>>", "items" ) },
                new CSharpParameter[ 0 ],
                new[]
                    {
                        new CSharpParameter( "Unit?", "width", "null" ), new CSharpParameter( "string", "defaultValueItemLabel", "\"\"" ),
                        new CSharpParameter( "bool", "placeholderIsValid", "false" ), new CSharpParameter( "string", "placeholderText", "\"Please select\"" ),
                        new CSharpParameter( "PostBack", "postBack", "null" ), new CSharpParameter( "bool", "autoPostBack", "false" )
                    },
                new CSharpParameter[ 0 ],
                "SelectList.CreateDropDown( items, v, width: width, defaultValueItemLabel: defaultValueItemLabel, placeholderIsValid: placeholderIsValid, placeholderText: placeholderText, postBack: postBack, autoPostBack: autoPostBack )",
                "control.ValidateAndGetSelectedItemIdInPostBack( postBackValues, validator )",
                "" );
            writeFormItemGetters(
                writer,
                field,
                "WysiwygHtmlEditor",
                "Html",
                "string",
                "\"\"",
                new CSharpParameter[ 0 ],
                getAllowEmptyParameter( false ).ToSingleElementArray(),
                new CSharpParameter( "string", "ckEditorConfiguration", "\"\"" ).ToSingleElementArray(),
                new CSharpParameter[ 0 ],
                "new WysiwygHtmlEditor( v, ckEditorConfiguration: ckEditorConfiguration )",
                "validator.GetString( new ValidationErrorHandler( subject ), control.GetPostBackValue( postBackValues ), allowEmpty" +
                ( field.Size.HasValue ? ", " + field.Size.Value : "" ) + " )",
                "",
                additionalSummarySentences:
                    new[]
                        {
                            "WARNING: Do not use this form-item getter unless you know exactly what you're doing.",
                            "If you want to store HTML, it is almost always better to use an HTML block instead of just a string field.",
                            "HTML blocks have special handling for intra-site URIs and may include additional features in the future.",
                            "They also cause all of your HTML to be stored in one place, which is usually a good practice."
                        } );
        }