public static ComponentBuilder <TConfig, TTag> AddContentAtEnd <TConfig, TTag>(this ComponentBuilder <TConfig, TTag> builder, object content) where TConfig : BootstrapConfig where TTag : Tag { if (content != null) { // Make sure that this isn't a component ComponentBuilder contentBuilder = content as ComponentBuilder; if (contentBuilder != null) { builder.Component.AddChildAtEnd(contentBuilder.GetComponent()); } // Now check if it's an IHtmlString string str; IHtmlString htmlString = content as IHtmlString; if (htmlString != null) { str = htmlString.ToHtmlString(); } else { // Just convert to a string using the standard conversion logic str = Convert.ToString(content, CultureInfo.InvariantCulture); } if (!string.IsNullOrEmpty(str)) { builder.Component.AddChildAtEnd(builder.GetHelper().Content(str)); } } return(builder); }
// Tag public static ComponentBuilder <TConfig, TTag> AddHtml <TConfig, TTag>(this ComponentBuilder <TConfig, TTag> builder, Func <dynamic, HelperResult> content) where TConfig : BootstrapConfig where TTag : Tag { builder.GetComponent().AddChild(builder.GetHelper().Content(content(null).ToHtmlString()).GetComponent()); return(builder); }
public static ComponentBuilder <MvcBootstrapConfig <TModel>, FormGroup> FormGroup <TComponent, TModel, TValue>( this BootstrapHelper <MvcBootstrapConfig <TModel>, TComponent> helper, Expression <Func <TModel, TValue> > labelExpression) where TComponent : Component, ICanCreate <FormGroup> { ComponentBuilder <MvcBootstrapConfig <TModel>, FormGroup> builder = helper.FormGroup(); builder.GetComponent().ControlLabel = builder.GetHelper().ControlLabel(labelExpression).GetComponent(); return(builder); }
// FormControl (instance) public static ComponentBuilder <TConfig, FormControl> FormControl <TConfig, TComponent>(this BootstrapHelper <TConfig, TComponent> helper, string label = null, string labelFor = null) where TConfig : BootstrapConfig where TComponent : Component, ICanCreate <FormControl> { ComponentBuilder <TConfig, FormControl> builder = new ComponentBuilder <TConfig, FormControl>(helper.Config, new FormControl(helper)); builder.Component.Label = builder.GetHelper().ControlLabel(label).For(labelFor).Component; return(builder); }
public static ComponentBuilder <TConfig, Button> For <TConfig, TModel, TType>( this ComponentBuilder <TConfig, Button> builder, Expression <Func <TModel, TType> > expression, TType value) where TConfig : BootstrapConfig { var html = builder.GetHelper() var metadata = ModelMetadata.FromLambdaExpression(expression, html.ViewData); return builder. }
public static ComponentBuilder <MvcBootstrapConfig <TModel>, FormGroup> SetGroupLabel <TModel, TValue, TThis>( this ComponentBuilder <MvcBootstrapConfig <TModel>, FormGroup> builder, Expression <Func <TModel, TValue> > expression, Action <ControlLabel> labelAction = null) { ControlLabel controlLabel = GetControlLabel(builder.GetHelper(), expression).GetComponent(); builder.GetComponent().ControlLabel = controlLabel; if (labelAction != null) { labelAction(controlLabel); } return(builder); }
// FormGroup public static ComponentBuilder <TConfig, FormGroup> FormGroup <TConfig, TComponent>(this BootstrapHelper <TConfig, TComponent> helper, string label = null, string labelFor = null) where TConfig : BootstrapConfig where TComponent : Component, ICanCreate <FormGroup> { ComponentBuilder <TConfig, FormGroup> builder = new ComponentBuilder <TConfig, FormGroup>(helper.Config, new FormGroup(helper)); if (label != null) { builder.Component.ControlLabel = builder.GetHelper().ControlLabel(label, labelFor).Component; } return(builder); }
public static ComponentBuilder <MvcBootstrapConfig <TModel>, TFormControl> SetControlLabel <TModel, TValue, TFormControl>( this ComponentBuilder <MvcBootstrapConfig <TModel>, TFormControl> builder, Expression <Func <TModel, TValue> > expression, Action <ControlLabel> labelAction = null) where TFormControl : FormControl { ControlLabel controlLabel = GetControlLabel(builder.GetHelper(), expression).For(builder.GetComponent().GetAttribute("name")).GetComponent(); if (labelAction != null) { labelAction(controlLabel); } builder.GetComponent().Label = controlLabel; return(builder); }
public static ComponentBuilder <TConfig, FormGroup> SetGroupLabel <TConfig>(this ComponentBuilder <TConfig, FormGroup> builder, string label, string labelFor = null, Action <ComponentBuilder <TConfig, ControlLabel> > labelAction = null) where TConfig : BootstrapConfig { if (label != null) { ComponentBuilder <TConfig, ControlLabel> controlLabelBuilder = builder.GetHelper().ControlLabel(label, labelFor); if (labelAction != null) { labelAction(controlLabelBuilder); } builder.Component.ControlLabel = controlLabelBuilder.Component; } return(builder); }
// FormControl public static ComponentBuilder <TConfig, TFormControl> SetControlLabel <TConfig, TFormControl>(this ComponentBuilder <TConfig, TFormControl> builder, string label, Action <ComponentBuilder <TConfig, ControlLabel> > labelAction = null) where TConfig : BootstrapConfig where TFormControl : FormControl { if (label != null) { ComponentBuilder <TConfig, ControlLabel> controlLabelBuilder = builder.GetHelper().ControlLabel(label).For(builder.Component.GetAttribute("name")); if (labelAction != null) { labelAction(controlLabelBuilder); } builder.Component.Label = controlLabelBuilder.Component; } else { builder.Component.Label = null; } return(builder); }