static void LoadWidgets(Assembly[] assemblies, Type builderType, IDefinedConventions registry) { foreach (var asm in assemblies) { asm.GetTypes().Where(t => t.InheritsGenericType(builderType)).OrderByAttribute() .ForEach(t => registry.Add(t.CreateInstance() as IBuildElement)); } }
void Editors(IDefinedConventions editor) { editor .PropertiesExceptOfType<bool>() .Modify((tag, model) => { var input = tag.FirstInputTag(); if (input == null || input.IsHiddenInput()) return tag; input.AddClass("form-control"); return tag; }) ; WrapFieldWithDiv(editor); }
void Editors(IDefinedConventions editor) { editor .PropertiesExceptOfType <bool>() .Modify((tag, model) => { var input = tag.FirstInputTag(); if (input == null || input.IsHiddenInput()) { return(tag); } input.AddClass("form-control"); return(tag); }) ; WrapFieldWithDiv(editor); }
protected virtual void WrapFieldWithDiv(IDefinedConventions editor) { editor. If(WhenToWrapFields) .Modify((tag, model) => { var wrapper = new DivTag(); if (tag is MvcCheckboxElement) { wrapper.AddClass("checkbox"); } else { wrapper.AddClass("form-group"); } if (model.ValidationFailed) { wrapper.AddClass("has-error"); } return tag.WrapWith(wrapper); }); }
protected virtual void WrapFieldWithDiv(IDefinedConventions editor) { editor. If(WhenToWrapFields) .Modify((tag, model) => { var wrapper = new DivTag(); if (tag is MvcCheckboxElement) { wrapper.AddClass("checkbox"); } else { wrapper.AddClass("form-group"); } if (model.ValidationFailed) { wrapper.AddClass("has-error"); } return(tag.WrapWith(wrapper)); }); }
static void LoadWidgets(Assembly[] assemblies, Type builderType, IDefinedConventions registry) { foreach (var asm in assemblies) { asm.GetTypes().Where(t => t.InheritsGenericType(builderType)).OrderByAttribute() .ForEach(t => registry.Add(t.CreateInstance() as IBuildElement)); } }
public static HtmlTag GenerateTags(this IDefinedConventions conventions, ModelInfo info) { var all = conventions.GetConventions(info); return(ModelTypeAdviser.GetGenerator(info, all).GenerateElement(info)); }
void Labels(IDefinedConventions label) { label.Always.Modify((tag, model) => tag.AddClass("control-label")); }
void Labels(IDefinedConventions label) { label.Always.Modify((tag, model) => tag.AddClass("control-label")); }