public TagPlan(ITagBuilder builder, IEnumerable<ITagModifier> modifiers, IElementNamingConvention elementNamingConvention) { Builder = builder; ElementNamingConvention = elementNamingConvention; _modifiers.AddRange(modifiers); // Important to force the enumerable to be executed no later than this point }
public TagPlan(ITagBuilder builder, IEnumerable <ITagModifier> modifiers, IElementNamingConvention elementNamingConvention) { Builder = builder; ElementNamingConvention = elementNamingConvention; _modifiers.AddRange(modifiers); // Important to force the enumerable to be executed no later than this point }
/// <summary> /// 添加子标签生成器 /// </summary> /// <param name="childBuilder">子标签生成器</param> public void AddChild(ITagBuilder childBuilder) { if (childBuilder == null) { return; } _childBuilders.Add(childBuilder); }
public void SetUp() { _loggingService = A.Fake <ILogService>(); _tagService = A.Fake <ITagService>(); _facebookService = A.Fake <IFacebookService>(); _tagBuilder = A.Fake <ITagBuilder>(); _controller = new TagController(_facebookService, _loggingService, _tagService, _tagBuilder); }
public CommonController(IFileSystem fileSystem, IRepository <FileRecord> fileRepo, IContentTypeProvider contentTypeProvider, ITagBuilder tagbuilder, ILogger <CommonController> logger) { _fileSystem = fileSystem; _fileRepo = fileRepo; _contentTypeProvider = contentTypeProvider; _logger = logger; _tagbuilder = tagbuilder; }
protected override void WriteSelf(System.IO.TextWriter writer) { var controlContext = GetNearestParent <IControlContext>(); ITagBuilder div = null; if (!Inline) { div = Helper.CreateTagBuilder("div"); div.AddCssClass("checkbox"); div.WriteStartTag(writer); } var lbl = Helper.CreateTagBuilder("label"); if (Inline) { lbl.AddCssClass("checkbox-inline"); } lbl.WriteStartTag(writer); var input = Helper.CreateTagBuilder("input"); input.MergeAttribute("type", "checkbox", true); if (controlContext != null) { input.MergeAttribute("id", controlContext.FieldName, true); input.MergeAttribute("name", controlContext.FieldName, true); input.MergeAttribute("value", "true", true); var controlValue = controlContext.FieldValue; if (controlValue != null && bool.Parse(controlValue.ToString())) { input.MergeAttribute("checked", "checked", true); } } if (Disabled) { input.MergeAttribute("disabled", "disabled", true); } ApplyCss(input); ApplyAttributes(input); ////input.MergeAttributes(helper.HtmlHelper.GetUnobtrusiveValidationAttributes(context.ExpressionText, context.Metadata)); input.WriteFullTag(writer); writer.Write(" "); // writing space to separate text from checkbox itself writer.Write(Helper.HtmlEncode(Text)); lbl.WriteEndTag(writer); if (div != null) { div.WriteEndTag(writer); } }
public CommonControllerSpecs(TestDiscussionWebApp app) { _app = app.Reset(); _fileRepo = _app.GetService <IRepository <FileRecord> >(); _fs = _app.GetService <IFileSystem>(); _tagBuilder = _app.GetService <ITagBuilder>(); _app.DeleteAll <FileRecord>(); }
/// <summary> /// Initializes a new instance of the <see cref="AssetService"/> class. /// </summary> /// <param name="sharedSettings">Shared settings.</param> /// <param name="manifestService">Asset manifest service.</param> /// <param name="tagBuilder">Asset builder service.</param> public AssetService(ISharedSettings sharedSettings, IManifestService manifestService, ITagBuilder tagBuilder) { if (sharedSettings == null) { throw new ArgumentNullException(nameof(sharedSettings)); } AssetsDirectoryPath = sharedSettings.AssetsDirectoryPath; AssetsWebPath = sharedSettings.AssetsWebPath; _manifestService = manifestService; _tagBuilder = tagBuilder; }
public void SetUp() { _loggingService = A.Fake <ILogService>(); _tagService = A.Fake <ITagService>(); _facebookService = A.Fake <IFacebookService>(); _complaintSeverityService = A.Fake <IComplaintSeverityService>(); _complaintService = A.Fake <IComplaintService>(); _userService = A.Fake <IUserService>(); _tagBuilder = A.Fake <ITagBuilder>(); _complaintBuilder = A.Fake <IComplaintBuilder>(); _controller = new ComplaintController(_facebookService, _loggingService, _tagService, _complaintSeverityService, _complaintService, _userService, _tagBuilder, _complaintBuilder); }
protected void ApplyCss(ITagBuilder tag) { if (additionalClasses == null) { return; } foreach (var value in additionalClasses) { if (!string.IsNullOrWhiteSpace(value)) { tag.AddCssClass(value); } } }
protected void ApplyAttributes(ITagBuilder tag) { if (additionalAttributes == null) { return; } foreach (var attr in additionalAttributes) { if (!string.IsNullOrWhiteSpace(attr.Value)) { tag.MergeAttribute(attr.Key, attr.Value, true); } } }
protected void ApplyAttributes(ITagBuilder tag) { if (additionalAttributes == null) { return; } foreach (var attr in additionalAttributes) { if (!string.IsNullOrWhiteSpace(attr.Value)) { tag.MergeAttribute(attr.Key, attr.Value); } } }
protected void ApplyCss(ITagBuilder tag) { if (additionalClasses == null) { return; } foreach (var value in additionalClasses) { if (!string.IsNullOrWhiteSpace(value)) { tag.AddCssClass(value); } } }
protected override string WriteSelfStartTag(System.IO.TextWriter writer, IBootstrapContext context) { var form = context.PeekNearest <IFormContext>(); var formGroup = context.PeekNearest <FormGroup>(); if (form != null && form.TypeValue == FormType.Inline) { return(string.Empty); } ITagBuilder tb = null; ITagBuilder tb2 = null; if (form != null && form.TypeValue == FormType.Horizontal) { tb = context.CreateTagBuilder("div"); tb.AddCssClass(form.ControlsWidthValue.ToCssClass()); if (WithoutLabelValue) { tb.AddCssClass(form.ControlsWidthValue.Invert().ToOffsetCssClass()); } ApplyCss(tb); ApplyAttributes(tb); tb.WriteStartTag(writer); } if (formGroup != null && formGroup.WithSizedControlValue) { tb2 = context.CreateTagBuilder("div"); tb2.AddCssClass("row"); tb2.WriteStartTag(writer); } if (tb != null && tb2 != null) { return(tb2.GetEndTag() + tb.GetEndTag()); } if (tb2 != null) { return(tb2.GetEndTag()); } if (tb != null) { return(tb.GetEndTag()); } return(string.Empty); }
public ComplaintBuilder(IComplaintSeverityBuilder complaintSeverityBuilder, ITagBuilder tagBuilder) { if (complaintSeverityBuilder == null) { throw new ArgumentNullException("complaintSeverityBuilder"); } if (tagBuilder == null) { throw new ArgumentNullException("tagBuilder"); } _complaintSeverityBuilder = complaintSeverityBuilder; _tagBuilder = tagBuilder; }
public ComplaintBuilder(IComplaintSeverityBuilder complaintSeverityBuilder, ITagBuilder tagBuilder) { if (complaintSeverityBuilder == null) { throw new ArgumentNullException("complaintSeverityBuilder"); } if (tagBuilder == null) { throw new ArgumentNullException("tagBuilder"); } _complaintSeverityBuilder = complaintSeverityBuilder; _tagBuilder = tagBuilder; }
public TagController(IFacebookService facebookService, ILogService loggingService, ITagService tagService, ITagBuilder tagBuilder) : base(facebookService, loggingService) { if (tagService == null) { throw new ArgumentNullException("tagService"); } if (tagBuilder == null) { throw new ArgumentNullException("tagBuilder"); } _tagService = tagService; _tagBuilder = tagBuilder; }
public TagController(IFacebookService facebookService, ILogService loggingService, ITagService tagService, ITagBuilder tagBuilder) : base(facebookService, loggingService) { if (tagService == null) { throw new ArgumentNullException("tagService"); } if (tagBuilder == null) { throw new ArgumentNullException("tagBuilder"); } _tagService = tagService; _tagBuilder = tagBuilder; }
public ComplaintController(IFacebookService facebookService, ILogService loggingService, ITagService tagService, IComplaintSeverityService complaintSeverityService, IComplaintService complaintService, IUserService userService, ITagBuilder tagBuilder, IComplaintBuilder complaintBuilder) : base(facebookService, loggingService) { if (complaintService == null) { throw new ArgumentNullException("complaintService"); } if (tagService == null) { throw new ArgumentNullException("tagService"); } if (complaintSeverityService == null) { throw new ArgumentNullException("complaintSeverityService"); } if (tagBuilder == null) { throw new ArgumentNullException("tagBuilder"); } if (complaintBuilder == null) { throw new ArgumentNullException("complaintBuilder"); } if (userService == null) { throw new ArgumentNullException("userService"); } _userService = userService; _tagBuilder = tagBuilder; _complaintBuilder = complaintBuilder; _complaintSeverityService = complaintSeverityService; _tagService = tagService; _complaintService = complaintService; }
public ComplaintController(IFacebookService facebookService, ILogService loggingService, ITagService tagService, IComplaintSeverityService complaintSeverityService, IComplaintService complaintService, IUserService userService, ITagBuilder tagBuilder, IComplaintBuilder complaintBuilder) : base(facebookService, loggingService) { if (complaintService == null) { throw new ArgumentNullException("complaintService"); } if (tagService == null) { throw new ArgumentNullException("tagService"); } if (complaintSeverityService == null) { throw new ArgumentNullException("complaintSeverityService"); } if (tagBuilder == null) { throw new ArgumentNullException("tagBuilder"); } if (complaintBuilder == null) { throw new ArgumentNullException("complaintBuilder"); } if (userService == null) { throw new ArgumentNullException("userService"); } _userService = userService; _tagBuilder = tagBuilder; _complaintBuilder = complaintBuilder; _complaintSeverityService = complaintSeverityService; _tagService = tagService; _complaintService = complaintService; }
private string WriteControlsStart(System.IO.TextWriter writer, IForm formContext, bool noLabel) { if (formContext != null && formContext.Type == FormType.Inline) { return(string.Empty); } ITagBuilder tb = null; ITagBuilder tb2 = null; if (formContext != null && formContext.Type == FormType.Horizontal) { tb = Helper.CreateTagBuilder("div"); tb.AddCssClass(formContext.ControlsWidth.ToCssClass()); if (noLabel) { tb.AddCssClass(formContext.ControlsWidth.Invert().ToOffsetCssClass()); } ApplyCss(tb); ApplyAttributes(tb); tb.WriteStartTag(writer); } if (WithSizedControl) { tb2 = Helper.CreateTagBuilder("div"); tb2.AddCssClass("row"); tb2.WriteStartTag(writer); } if (tb != null && tb2 != null) { return(tb2.GetEndTag() + tb.GetEndTag()); } if (tb2 != null) { return(tb2.GetEndTag()); } if (tb != null) { return(tb.GetEndTag()); } return(string.Empty); }
public void SetUp() { b1 = MockRepository.GenerateMock <ITagBuilder <FakeSubject> >(); b2 = MockRepository.GenerateMock <ITagBuilder <FakeSubject> >(); b3 = MockRepository.GenerateMock <ITagBuilder <FakeSubject> >(); b4 = MockRepository.GenerateMock <ITagBuilder <FakeSubject> >(); b5 = MockRepository.GenerateMock <ITagBuilder <FakeSubject> >(); b6 = MockRepository.GenerateMock <ITagBuilder <FakeSubject> >(); b7 = MockRepository.GenerateMock <ITagBuilder <FakeSubject> >(); b8 = MockRepository.GenerateMock <ITagBuilder <FakeSubject> >(); m1 = MockRepository.GenerateMock <ITagModifier <FakeSubject> >(); m2 = MockRepository.GenerateMock <ITagModifier <FakeSubject> >(); m3 = MockRepository.GenerateMock <ITagModifier <FakeSubject> >(); m4 = MockRepository.GenerateMock <ITagModifier <FakeSubject> >(); m5 = MockRepository.GenerateMock <ITagModifier <FakeSubject> >(); category1 = new TagCategory <FakeSubject>(); category1.Add(b1); category1.Add(b2); category1.Add(m1); category1.Add(m2); category1.ForProfile("A").Add(b3); category1.ForProfile("A").Add(m3); category1.ForProfile("B").Add(b4); category1.ForProfile("D").Add(b8); var category2 = new TagCategory <FakeSubject>(); category2.Add(b5); category2.Add(m4); category2.ForProfile("A").Add(b6); category2.ForProfile("C").Add(b7); category2.ForProfile("B").Add(m5); category1.Import(category2); }
private ITagBuilder WrapInListItem(ITagBuilder inner, PagedListRenderOptions options, params string[] classes) { var li = _tagBuilderFactory .Create("li"); foreach (var @class in classes) { li.AddCssClass(@class); } if (options != null) { if (options.FunctionToTransformEachPageLink != null) { return(options.FunctionToTransformEachPageLink(li, inner)); } } AppendHtml(li, TagBuilderToString(inner)); return(li); }
public void SetUp() { b1 = MockRepository.GenerateMock <ITagBuilder <FakeSubject> >(); b2 = MockRepository.GenerateMock <ITagBuilder <FakeSubject> >(); b3 = MockRepository.GenerateMock <ITagBuilder <FakeSubject> >(); b4 = MockRepository.GenerateMock <ITagBuilder <FakeSubject> >(); b5 = MockRepository.GenerateMock <ITagBuilder <FakeSubject> >(); b6 = MockRepository.GenerateMock <ITagBuilder <FakeSubject> >(); b7 = MockRepository.GenerateMock <ITagBuilder <FakeSubject> >(); m1 = MockRepository.GenerateMock <ITagModifier <FakeSubject> >(); m2 = MockRepository.GenerateMock <ITagModifier <FakeSubject> >(); m3 = MockRepository.GenerateMock <ITagModifier <FakeSubject> >(); m4 = MockRepository.GenerateMock <ITagModifier <FakeSubject> >(); library1 = new TagLibrary <FakeSubject>(); library1.Add(b1); library1.Add(m1); library1.Default.Profile("A").Add(b2); library1.Default.Profile("A").Add(m2); library1.Category("Cat1").Add(b3); library1.Category("Cat1").Add(m3); library1.Category("Cat1").Profile("A").Add(b4); var library2 = new TagLibrary <FakeSubject>(); library2.Add(b5); library2.Add(m4); library2.Category("Cat2").Add(b6); library2.Category("Cat1").Add(b7); library1.Import(library2); }
private static string TagBuilderToString(ITagBuilder tagBuilder) { return(tagBuilder .ToString(TagRenderMode.Normal)); }
private static void SetInnerText(ITagBuilder tagBuilder, string innerText) { tagBuilder.SetInnerText(innerText); }
/// <summary> /// Adds a builder to the default category and profile /// </summary> /// <param name="builder"></param> public void Add(ITagBuilder <T> builder) { Default.Add(builder); }
public void Add(Func<ElementRequest, bool> filter, ITagBuilder builder) { _policies.Add(new ConditionalTagBuilderPolicy(filter, builder)); }
/// <summary> /// 设置父标签生成器 /// </summary> /// <param name="parentBuilder">父标签生成器</param> public void SetParent( ITagBuilder parentBuilder ) { _parentBuilder = parentBuilder; }
public void SetUp() { b1 = MockRepository.GenerateMock<ITagBuilder<FakeSubject>>(); b2 = MockRepository.GenerateMock<ITagBuilder<FakeSubject>>(); b3 = MockRepository.GenerateMock<ITagBuilder<FakeSubject>>(); b4 = MockRepository.GenerateMock<ITagBuilder<FakeSubject>>(); b5 = MockRepository.GenerateMock<ITagBuilder<FakeSubject>>(); b6 = MockRepository.GenerateMock<ITagBuilder<FakeSubject>>(); b7 = MockRepository.GenerateMock<ITagBuilder<FakeSubject>>(); b8 = MockRepository.GenerateMock<ITagBuilder<FakeSubject>>(); m1 = MockRepository.GenerateMock<ITagModifier<FakeSubject>>(); m2 = MockRepository.GenerateMock<ITagModifier<FakeSubject>>(); m3 = MockRepository.GenerateMock<ITagModifier<FakeSubject>>(); m4 = MockRepository.GenerateMock<ITagModifier<FakeSubject>>(); m5 = MockRepository.GenerateMock<ITagModifier<FakeSubject>>(); category1 = new TagCategory<FakeSubject>(); category1.Add(b1); category1.Add(b2); category1.Add(m1); category1.Add(m2); category1.ForProfile("A").Add(b3); category1.ForProfile("A").Add(m3); category1.ForProfile("B").Add(b4); category1.ForProfile("D").Add(b8); var category2 = new TagCategory<FakeSubject>(); category2.Add(b5); category2.Add(m4); category2.ForProfile("A").Add(b6); category2.ForProfile("C").Add(b7); category2.ForProfile("B").Add(m5); category1.Import(category2); }
public void Add(ITagBuilder <T> builder) { _builders.Add(builder); }
/// <summary> /// 清除外围html /// </summary> public void ClearOuterHtml() { _parentBuilder = null; BeforeHtml = string.Empty; AfterHtml = string.Empty; }
public void SetUp() { b1 = MockRepository.GenerateMock<ITagBuilder<FakeSubject>>(); b2 = MockRepository.GenerateMock<ITagBuilder<FakeSubject>>(); b3 = MockRepository.GenerateMock<ITagBuilder<FakeSubject>>(); b4 = MockRepository.GenerateMock<ITagBuilder<FakeSubject>>(); b5 = MockRepository.GenerateMock<ITagBuilder<FakeSubject>>(); b6 = MockRepository.GenerateMock<ITagBuilder<FakeSubject>>(); b7 = MockRepository.GenerateMock<ITagBuilder<FakeSubject>>(); m1 = MockRepository.GenerateMock<ITagModifier<FakeSubject>>(); m2 = MockRepository.GenerateMock<ITagModifier<FakeSubject>>(); m3 = MockRepository.GenerateMock<ITagModifier<FakeSubject>>(); m4 = MockRepository.GenerateMock<ITagModifier<FakeSubject>>(); library1 = new TagLibrary<FakeSubject>(); library1.Add(b1); library1.Add(m1); library1.Default.Profile("A").Add(b2); library1.Default.Profile("A").Add(m2); library1.Category("Cat1").Add(b3); library1.Category("Cat1").Add(m3); library1.Category("Cat1").Profile("A").Add(b4); var library2 = new TagLibrary<FakeSubject>(); library2.Add(b5); library2.Add(m4); library2.Category("Cat2").Add(b6); library2.Category("Cat1").Add(b7); library1.Import(library2); }
public void SetUp() { _loggingService = A.Fake<ILogService>(); _tagService = A.Fake<ITagService>(); _facebookService = A.Fake<IFacebookService>(); _complaintSeverityService = A.Fake<IComplaintSeverityService>(); _complaintService = A.Fake<IComplaintService>(); _userService = A.Fake<IUserService>(); _tagBuilder = A.Fake<ITagBuilder>(); _complaintBuilder = A.Fake<IComplaintBuilder>(); _controller = new ComplaintController(_facebookService, _loggingService, _tagService, _complaintSeverityService, _complaintService, _userService, _tagBuilder, _complaintBuilder); }
public void Add(Func <ElementRequest, bool> filter, ITagBuilder builder) => Add(new ConditionalTagBuilderPolicy(filter, builder));
public void Register(string nodeName, ITagBuilder tagBuilder) { _tagBuilderMap.Add(nodeName, tagBuilder); }
/// <summary> /// 更新标签前组件 /// </summary> /// <param name="tagBuilder">标签生成器</param> public void UpdateBefore( ITagBuilder tagBuilder ) { BeforeHtml = tagBuilder.GetResult(); }
/// <summary> /// 添加子标签生成器 /// </summary> /// <param name="childBuilder">子标签生成器</param> public void AddChild( ITagBuilder childBuilder ) { if ( childBuilder == null ) return; _childBuilders.Add( childBuilder ); }
/// <summary> /// 在标签前添加组件 /// </summary> /// <param name="tagBuilder">标签生成器</param> public void AddBefore( ITagBuilder tagBuilder ) { BeforeHtml += tagBuilder.GetResult(); }
protected override void WriteSelf(System.IO.TextWriter writer, IBootstrapContext context) { var form = context.PeekNearest <IFormContext>(); var formGroup = context.PeekNearest <FormGroup>(); if (formGroup != null && ControlContextValue == null) { ControlContextValue = formGroup.ControlContextValue; } ITagBuilder div = null; if (!SizeValue.IsEmpty()) { // Inline forms does not support sized controls (we need 'some other' sizing rules?) if (form != null && form.TypeValue != FormType.Inline) { if (formGroup != null && formGroup.WithSizedControlValue) { div = context.CreateTagBuilder("div"); div.AddCssClass(SizeValue.ToCssClass()); writer.Write(div.GetStartTag()); } else { throw new InvalidOperationException("Size not allowed - call WithSizedControls() on FormGroup."); } } } var input = context.CreateTagBuilder("input"); input.AddCssClass("form-control"); var actualType = TypeValue; if (actualType != InputType.File && ControlContextValue != null) { input.MergeAttribute("id", ControlContextValue.Name); input.MergeAttribute("name", ControlContextValue.Name); if (ControlContextValue.IsRequired) { input.MergeAttribute("required", "required"); } var value = ControlContextValue.Value; if (value != null) { var valueString = value.ToString(); if (TypeValue == InputType.Date || TypeValue == InputType.Datetime || TypeValue == InputType.DatetimeLocal || TypeValue == InputType.Time) { var valueDateTime = value as DateTime?; var valueDateTimeOffset = value as DateTimeOffset?; var valueTimeSpan = value as TimeSpan?; if (valueDateTimeOffset.HasValue) { valueDateTime = valueDateTimeOffset.Value.DateTime; } if (valueDateTime.HasValue) { valueTimeSpan = valueDateTime.Value.TimeOfDay; } var asHtml5 = (DateInputMode == BootstrapMvc.DateInputMode.Html5); if (!asHtml5) { actualType = InputType.Text; } switch (TypeValue) { case InputType.Date: if (valueDateTime.HasValue) { valueString = asHtml5 ? valueDateTime.Value.ToString("yyyy-MM-dd") : valueDateTime.Value.ToString("d"); } break; case InputType.DatetimeLocal: if (valueDateTime.HasValue) { valueString = asHtml5 ? valueDateTime.Value.ToString("o") : valueDateTime.Value.ToString(); } break; case InputType.Datetime: if (valueDateTime.HasValue) { valueString = asHtml5 ? valueDateTimeOffset.Value.ToString("o") : valueDateTimeOffset.Value.ToString(); } break; case InputType.Time: if (valueDateTime.HasValue) { valueString = valueTimeSpan.ToString(); } break; } } input.MergeAttribute("value", valueString); } } if (actualType != InputType.Text) { input.MergeAttribute("type", actualType.ToType()); } if (DisabledValue) { input.MergeAttribute("disabled", "disabled"); } ApplyCss(input); ApplyAttributes(input); ////input.MergeAttributes(helper.HtmlHelper.GetUnobtrusiveValidationAttributes(context.ExpressionText, context.Metadata)); writer.Write(input.GetFullTag()); if (div != null) { writer.Write(div.GetEndTag()); } }
public void Add(Func <T, bool> filter, ITagBuilder <T> builder) { _policies.Add(new ConditionalTagBuilderPolicy <T>(filter, builder)); }
public ConditionalTagBuilderPolicy(Func<ElementRequest, bool> filter, Func<ElementRequest, HtmlTag> builder) { _filter = filter; _builder = new LambdaTagBuilder(builder); }
protected override void WriteSelf(System.IO.TextWriter writer) { var formContext = GetNearestParent <IForm>(); var formGroupContext = GetNearestParent <FormGroup>(); var controlContext = GetNearestParent <IControlContext>(); ITagBuilder div = null; if (!Size.IsEmpty()) { // Inline forms does not support sized controls (we need 'some other' sizing rules?) if (formContext != null && formContext.Type != FormType.Inline) { if (formGroupContext != null && formGroupContext.WithSizedControl) { div = Helper.CreateTagBuilder("div"); div.AddCssClass(Size.ToCssClass()); div.WriteStartTag(writer); } else { throw new InvalidOperationException("Size not allowed - call WithSizedControls() on FormGroup."); } } } var input = Helper.CreateTagBuilder("input"); #if BOOTSTRAP3 input.AddCssClass("form-control"); #endif #if BOOTSTRAP4 if (Type == InputType.File) { input.AddCssClass("form-control-file"); } else { input.AddCssClass("form-control"); } if (controlContext != null) { if (controlContext.HasErrors) { input.AddCssClass("form-control-danger"); } else if (controlContext.HasWarning) { input.AddCssClass("form-control-warning"); } } #endif var actualType = Type; if (actualType != InputType.File && controlContext != null) { input.MergeAttribute("id", controlContext.FieldName, true); input.MergeAttribute("name", controlContext.FieldName, true); if (controlContext.IsRequired) { input.MergeAttribute("required", "required", true); } var value = controlContext.FieldValue; if (value != null) { var valueString = value.ToString(); if (actualType == InputType.Datetime) { actualType = InputType.DatetimeLocal; } if (actualType == InputType.Date || actualType == InputType.DatetimeLocal || actualType == InputType.Time) { var valueDateTime = value as DateTime?; var valueDateTimeOffset = value as DateTimeOffset?; var valueTimeSpan = value as TimeSpan?; if (valueDateTimeOffset.HasValue) { valueDateTime = valueDateTimeOffset.Value.DateTime; } if (valueDateTime.HasValue) { valueTimeSpan = valueDateTime.Value.TimeOfDay; } var asHtml5 = (DateInputMode == BootstrapMvc.DateInputMode.Html5); if (!asHtml5) { actualType = InputType.Text; } switch (Type) { case InputType.Date: if (valueDateTime.HasValue) { valueString = asHtml5 ? valueDateTime.Value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture) : valueDateTime.Value.ToString(TextDateInputModeDateFormat); } break; case InputType.DatetimeLocal: if (valueDateTime.HasValue) { valueString = asHtml5 ? valueDateTime.Value.ToString("yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture) : valueDateTime.Value.ToString(TextDateInputModeDateTimeLocalFormat); } break; case InputType.Time: if (valueTimeSpan.HasValue) { valueString = DateTime.MinValue.Add(valueTimeSpan.Value).ToString("HH:mm:ss", CultureInfo.InvariantCulture); } break; } } input.MergeAttribute("value", valueString, true); } } if (actualType != InputType.Text) { input.MergeAttribute("type", actualType.ToType(), true); } if (Disabled) { input.MergeAttribute("disabled", "disabled", true); } ApplyCss(input); ApplyAttributes(input); ////input.MergeAttributes(helper.HtmlHelper.GetUnobtrusiveValidationAttributes(context.ExpressionText, context.Metadata)); input.WriteFullTag(writer); if (div != null) { div.WriteEndTag(writer); } }
public ConditionalTagBuilderPolicy(Func<ElementRequest, bool> filter, ITagBuilder builder) { _filter = filter; _builder = builder; }
private static void AppendHtml(ITagBuilder tagBuilder, string innerHtml) { tagBuilder.AppendHtml(innerHtml); }
/// <summary> /// 更新标签后组件 /// </summary> /// <param name="tagBuilder">标签生成器</param> public void UpdateAfter( ITagBuilder tagBuilder ) { AfterHtml = tagBuilder.GetResult(); }
private static string TagBuilderToString(ITagBuilder tagBuilder, TagRenderMode renderMode) { return(tagBuilder .ToString(renderMode)); }
/// <summary> /// 在标签后添加组件 /// </summary> /// <param name="tagBuilder">标签生成器</param> public void AddAfter( ITagBuilder tagBuilder ) { AfterHtml += tagBuilder.GetResult(); }
protected override void WriteSelf(System.IO.TextWriter writer) { var bootstrap4Mode = false; #if BOOTSTRAP4 bootstrap4Mode = true; #endif var controlContext = GetNearestParent <IControlContext>(); ITagBuilder div = null; ITagBuilder lbl = null; if (bootstrap4Mode) { div = Helper.CreateTagBuilder("div"); div.AddCssClass("form-check"); if (Inline) { div.AddCssClass("form-check-inline"); } if (controlContext != null) { if (controlContext.HasErrors) { div.AddCssClass("has-danger"); } else if (controlContext.HasWarning) { div.AddCssClass("has-warning"); } } lbl = Helper.CreateTagBuilder("label"); lbl.AddCssClass("form-check-label"); } else { if (!Inline) { div = Helper.CreateTagBuilder("div"); div.AddCssClass("radio"); } lbl = Helper.CreateTagBuilder("label"); if (Inline) { lbl.AddCssClass("radio-inline"); } } div?.WriteStartTag(writer); lbl?.WriteStartTag(writer); var input = Helper.CreateTagBuilder("input"); input.MergeAttribute("type", "radio", true); if (bootstrap4Mode) { input.AddCssClass("form-check-input"); } if (controlContext != null) { input.MergeAttribute("id", controlContext.FieldName, true); input.MergeAttribute("name", controlContext.FieldName, true); input.MergeAttribute("value", Value?.ToString(), true); var controlValue = controlContext.FieldValue; if (controlValue != null && Value != null && Value.ToString().Equals(controlValue.ToString())) { input.MergeAttribute("checked", "checked", true); } } if (Disabled) { input.MergeAttribute("disabled", "disabled", true); } ApplyCss(input); ApplyAttributes(input); ////input.MergeAttributes(helper.HtmlHelper.GetUnobtrusiveValidationAttributes(context.ExpressionText, context.Metadata)); input.WriteFullTag(writer); writer.Write(" "); // writing space to separate text from radio itself writer.Write(Helper.HtmlEncode(Text ?? controlContext?.DisplayName)); lbl?.WriteEndTag(writer); div?.WriteEndTag(writer); }
public void SetUp() { _loggingService = A.Fake<ILogService>(); _tagService = A.Fake<ITagService>(); _facebookService = A.Fake<IFacebookService>(); _tagBuilder = A.Fake<ITagBuilder>(); _controller = new TagController(_facebookService, _loggingService, _tagService, _tagBuilder); }