public DefaultServerGridLayoutOptions( ContextualizedHelpers helpers, IList<RowType> rows, IList<KeyValuePair<string, string>> toolbars, Template<LayoutTemplateOptions> layoutTemplate, IEnumerable<Template<LayoutTemplateOptions>> subTemplates, IHtmlContent mainContent, GridType type, string id, string prefix, GridErrorMessages messages, string cssClass, string caption, Type localizerType ) : base(rows, toolbars, layoutTemplate, subTemplates, mainContent) { this.helpers = helpers; Type = type; Messages = messages; Id = id; Prefix = prefix; CssClass = cssClass; Caption = caption; var first = rows.FirstOrDefault(); MustAddButtonColumn = first.MustAddButtonColumn(helpers, Type== GridType.Batch); VisibleColumns = first.VisibleColumns(helpers, Type == GridType.Batch); LocalizerType = localizerType; Localizer = LocalizerType != null ? helpers.LocalizerFactory.Create(LocalizerType) : null; }
public DefaultServerDetailLayoutOptions( ContextualizedHelpers helpers, IList<RowType> rows, IList<KeyValuePair<string, string>> toolbars, Template<LayoutTemplateOptions> layoutTemplate, IEnumerable<Template<LayoutTemplateOptions>> subTemplates, IHtmlContent mainContent, string id, string prefix, string cssClass, Type localizerType, bool editMode, string formAction, string formMethod, bool? antiforgery, bool noSubmit=false ) : base(rows, toolbars, layoutTemplate, subTemplates, mainContent) { this.helpers = helpers; Id = id; Prefix = prefix; CssClass = cssClass; LocalizerType = localizerType; Localizer = LocalizerType != null ? helpers.LocalizerFactory.Create(LocalizerType) : null; EditMode = editMode; Antiforgery = antiforgery; FormAction = formAction; FormMethod = formMethod; NoSubmit = noSubmit; }
/// <summary> /// Initializes a new <see cref="HtmlContentViewComponentResult"/>. /// </summary> public HtmlContentViewComponentResult(IHtmlContent encodedContent) { if (encodedContent == null) { throw new ArgumentNullException(nameof(encodedContent)); } EncodedContent = encodedContent; }
public static void Prepend(this TagHelperContent content, IHtmlContent value) { if (content.IsEmpty) content.SetContent(value); else { string currentContent = content.GetContent(); content.SetContent(value); content.AppendHtml(currentContent); } }
public void AddSegment(IHtmlContent titlePart, string position) { _title = null; _titleParts.Add(new PositionalTitlePart { Value = titlePart, Position = position }); }
/// <inheritdoc /> public IHtmlContentBuilder AppendHtml(IHtmlContent content) { if (content == null) { return this; } AppendValue(new ViewBufferValue(content)); return this; }
public static string HtmlContentToString(IHtmlContent content, IHtmlEncoder encoder = null) { if (encoder == null) { encoder = new CommonTestEncoder(); } using (var writer = new StringWriter()) { content.WriteTo(writer, encoder); return writer.ToString(); } }
/// <summary> /// Wraps the template for a single property in a div and adds a label /// </summary> /// <param name="htmlHelper">The HTML helper.</param> /// <param name="propertyMetadata">The property metadata.</param> /// <param name="template">The template.</param> protected override IHtmlContent WrapProperty(IHtmlHelper htmlHelper, ModelMetadata propertyMetadata, IHtmlContent template) { Guard.NotNull(propertyMetadata, nameof(propertyMetadata)); var builder = new HtmlContentBuilder(); var label = propertyMetadata.GetDisplayName(); if (!string.IsNullOrEmpty(label)) { var labelTag = HtmlTag.Division; labelTag.InnerHtml.SetContent(label); labelTag.AddCssClass("display-label"); builder.AppendLine(labelTag); } var valueDivTag = HtmlTag.Division; valueDivTag.AddCssClass("display-field"); valueDivTag.InnerHtml.SetHtmlContent(template); builder.AppendLine(valueDivTag); return(builder); }
/// <summary> /// Sets the content to the <see cref="IHtmlContent"/> value. /// </summary> /// <param name="builder">The <see cref="IHtmlContentBuilder"/>.</param> /// <param name="content">The <see cref="IHtmlContent"/> value that replaces the content.</param> /// <returns>The <see cref="IHtmlContentBuilder"/>.</returns> public static IHtmlContentBuilder SetHtmlContent(this IHtmlContentBuilder builder, IHtmlContent content) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } builder.Clear(); builder.AppendHtml(content); return builder; }
/// <summary> /// Wraps <see cref="contentStart"/> and <see cref="contentEnd"/> around <see cref="content"/> /// </summary> public static void Wrap(TagHelperContent content, IHtmlContent contentStart, IHtmlContent contentEnd) { content.Prepend(contentStart); content.AppendHtml(contentEnd); }
/// <inheritdoc /> public override void Write(IHtmlContent value) { _content.Append(value); }
public ScriptBlock(IHtmlContent content) : this(content, null) { }
public IHtmlContentBuilder Append(IHtmlContent content) { Entries.Add(content); return(this); }
public IncHtmlString(IHtmlContent result) { this.result = result; }
public TBuilder Content(IHtmlContent value) { Item.Content = value; return(this as TBuilder); }
/// <summary> /// Initializes a new instance of <see cref="ViewBufferValue"/> with a <see cref="IHtmlContent"/> value. /// </summary> /// <param name="content">The <see cref="IHtmlContent"/>.</param> public ViewBufferValue(IHtmlContent content) { Value = content; }
public TagHelperContent SetHtmlContent(IHtmlContent htmlContent) { return(this); }
public Button Content(IHtmlContent content) { _content = content; return(this); }
public Button(IHtmlHelper html, string type, IHtmlContent content) : base(html) { Type(type); Content(content); }
/// <inheritdoc /> IHtmlContentBuilder IHtmlContentBuilder.Append(IHtmlContent content) { return Append(content); }
/// <summary> /// Appends <paramref name="htmlContent"/> to the existing content. /// </summary> /// <param name="htmlContent">The <see cref="IHtmlContent"/> to be appended.</param> /// <returns>A reference to this instance after the append operation has completed.</returns> public abstract TagHelperContent Append(IHtmlContent htmlContent);
/// <summary>输出字符串</summary> /// <param name="Html"></param> /// <param name="name"></param> /// <param name="value"></param> /// <param name="length"></param> /// <param name="htmlAttributes"></param> /// <returns></returns> public static IHtmlContent ForString(this IHtmlHelper Html, String name, String value, Int32 length = 0, Object htmlAttributes = null) { var atts = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes); //if (!atts.ContainsKey("class")) atts.Add("class", "col-xs-10 col-sm-5"); //if (!atts.ContainsKey("class")) atts.Add("class", "col-xs-12 col-sm-8 col-md-6 col-lg-4"); if (!atts.ContainsKey("class")) { atts.Add("class", "form-control"); } // 首先输出图标 var ico = ""; IHtmlContent txt = null; if (name.EqualIgnoreCase("Pass", "Password")) { txt = Html.Password(name, value, atts); } else if (name.EqualIgnoreCase("Phone")) { ico = "<span class=\"input-group-addon\"><i class=\"glyphicon glyphicon-phone-alt\"></i></span>"; if (!atts.ContainsKey("type")) { atts.Add("type", "tel"); } txt = Html.TextBox(name, value, atts); } else if (name.EqualIgnoreCase("MobilePhone", "CellularPhone")) { ico = "<span class=\"input-group-addon\"><i class=\"glyphicon glyphicon-phone\"></i></span>"; if (!atts.ContainsKey("type")) { atts.Add("type", "tel"); } txt = Html.TextBox(name, value, atts); } else if (name.EqualIgnoreCase("email", "mail")) { ico = "<span class=\"input-group-addon\"><i class=\"glyphicon glyphicon-envelope\"></i></span>"; if (!atts.ContainsKey("type")) { atts.Add("type", "email"); } txt = Html.TextBox(name, value, atts); } else if (name.EndsWithIgnoreCase("url")) { ico = "<span class=\"input-group-addon\"><i class=\"glyphicon glyphicon-home\"></i></span>"; //if (!atts.ContainsKey("type")) atts.Add("type", "url"); txt = Html.TextBox(name, value, atts); } else if (length < 0 || length > 300) { txt = Html.TextArea(name, value, 3, 20, atts); } else { txt = Html.TextBox(name, value, atts); } var icog = "<div class=\"input-group\">{0}</div>"; var html = !String.IsNullOrWhiteSpace(ico) ? String.Format(icog, ico + txt.GetString()) : txt.GetString(); return(Html.Raw(html)); }
private void VerifyContentLinks(IHtmlContent html, string path, ContentLinkType contentType, ILookup<string, string> lookup) { var xmlDoc = new XmlDocument(); var doc = xmlDoc.CreateDocumentFragment(); using (var writer = new StringWriter()) { html.WriteTo(writer, HtmlEncoder.Default); doc.InnerXml = writer.ToString(); } var childNodes = doc.ChildNodes.Cast<XmlNode>().Where(n => !(n is XmlWhitespace)).ToList(); var expectedList = lookup[path]; Assert.Equal(expectedList.Count(), childNodes.Count); foreach (var pair in childNodes.Zip(expectedList, Tuple.Create)) { var node = pair.Item1; var expected = pair.Item2; if (contentType == ContentLinkType.Javascript) { Assert.Equal("script", node.Name); Assert.Equal(2, node.Attributes.Count); Assert.Equal("text/javascript", node.Attributes.GetNamedItem("type").Value); Assert.Equal(expected, node.Attributes.GetNamedItem("src").Value); } else { Assert.Equal("link", node.Name); Assert.Equal(2, node.Attributes.Count); Assert.Equal("stylesheet", node.Attributes.GetNamedItem("rel").Value); Assert.Equal(expected, node.Attributes.GetNamedItem("href").Value); } } }
/// <summary> /// Sets the content. /// </summary> /// <param name="htmlContent">The <see cref="IHtmlContent"/> that replaces the content.</param> /// <returns>A reference to this instance after the set operation has completed.</returns> public TagHelperContent SetContent(IHtmlContent htmlContent) { Clear(); Append(htmlContent); return(this); }
public void Append(IHtmlContent content) { _entries.Add(content); }
/// <inheritdoc /> public override TagHelperContent AppendHtml(IHtmlContent htmlContent) => AppendCore(htmlContent);
public ScriptBlock( IHtmlContent content, Dictionary <string, object> attributes) : this(content, attributes, int.MaxValue) { }
public HtmlContentValue(IHtmlContent value) { _value = value; }
public static IHtmlContent AppendTo(this IHtmlContent component, IList <IHtmlContent> controls) { controls.Add(component); return(component); }
public void OnGet() { Message = _loc["Hello"]; }
public static void Render(this IHtmlContent component, TextWriter writer) { component.WriteTo(writer, App.DefaultEncoder); }
/// <summary> /// Writes an <see cref="IHtmlContent"/> value. /// </summary> /// <param name="value">The <see cref="IHtmlContent"/> value.</param> public abstract void Write(IHtmlContent value);
/// <summary> /// se eu quiser esconder algo,por exempllo se eu quiser mostrar o link se o usuario tiver determinada claim /// </summary> /// <param name="page"></param> /// <param name="context"></param> /// <param name="claimName"></param> /// <param name="claimValue"></param> /// <returns></returns> public static IHtmlContent IfClaimShow(this IHtmlContent page, HttpContext context, string claimName, string claimValue) { return(CustomAuthorization.ValidarClaimsUsuario(context, claimName, claimValue) ? page : null); }
private String ToString(IHtmlContent content) { using (StringWriter writer = new StringWriter()) { content.WriteTo(writer, HtmlEncoder.Default); return writer.ToString(); } }
public PositionWrapper(string value, string position) { _value = new HtmlString(HtmlEncoder.Default.Encode(value)); Position = position; }
/// <summary> /// Sets the content. /// </summary> /// <param name="htmlContent">The <see cref="IHtmlContent"/> that replaces the content.</param> /// <returns>A reference to this instance after the set operation has completed.</returns> public TagHelperContent SetContent(IHtmlContent htmlContent) { HtmlContentBuilderExtensions.SetContent(this, htmlContent); return this; }
/// <inheritdoc /> public override TagHelperContent Append(IHtmlContent htmlContent) { Buffer.Append(htmlContent); return this; }
public PositionWrapper(string value, string position) { _value = new StringHtmlContent(value); Position = position; }
private static HtmlFormatter <T> CreateForSequence(bool includeInternals) { IDestructurer destructurer = null; if (typeof(T).IsConstructedGenericType) { var dictionaryType = typeof(T).GetInterfaces() .FirstOrDefault(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IDictionary <,>)); if (dictionaryType != null) { var itemType = dictionaryType.GenericTypeArguments.ElementAt(1); destructurer = Destructurer.Create(itemType); } if (destructurer == null) { var ienumerableType = typeof(T).GetInterfaces() .FirstOrDefault(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IEnumerable <>)); if (ienumerableType != null) { var itemType = ienumerableType.GenericTypeArguments.Single(); destructurer = Destructurer.Create(itemType); } } } return(new HtmlFormatter <T>((instance, writer) => { var index = 0; IEnumerable sequence = instance switch { IDictionary d => d.Values, IEnumerable s => s, _ => throw new ArgumentException($"{instance.GetType()} is not IEnumerable") }; IHtmlContent indexHeader = null; Func <string> getIndex; switch (instance) { case IDictionary dict: var keys = new string[dict.Keys.Count]; dict.Keys.CopyTo(keys, 0); getIndex = () => keys[index]; indexHeader = th(i("key")); break; default: getIndex = () => index.ToString(); indexHeader = th(i("index")); break; } var rows = new List <IHtmlContent>(); List <IHtmlContent> headers = null; foreach (var item in sequence) { var dictionary = (destructurer ?? Destructurer.Create(item.GetType())).Destructure(item); if (headers == null) { headers = new List <IHtmlContent>(); headers.Add(indexHeader); headers.AddRange(dictionary.Keys .Select(k => (IHtmlContent)th(k))); } var cells = new IHtmlContent[] { td(getIndex().ToHtmlContent()) } .Concat( dictionary .Values .Select(v => (IHtmlContent)td(v))); rows.Add(tr(cells)); index++; } var view = HtmlFormatter.Table(headers, rows); view.WriteTo(writer, HtmlEncoder.Default); })); }
private static IHtmlContent WrapFieldDropDownFor(IHtmlHelper html, IHtmlContent fieldHtml, IDictionary <string, object> htmlAttributes) { return(fieldHtml); }
private static void AddtoDictionary(Dictionary<string, string> dictionary, string name, IHtmlContent value) { if (value != null) { dictionary[name] = value.Text; } }
/// <summary> /// Sets the content to the <see cref="IHtmlContent"/> value. /// </summary> /// <param name="builder">The <see cref="IHtmlContentBuilder"/>.</param> /// <param name="content">The <see cref="IHtmlContent"/> value that replaces the content.</param> /// <returns>The <see cref="IHtmlContentBuilder"/>.</returns> public static IHtmlContentBuilder SetHtmlContent(this IHtmlContentBuilder builder, IHtmlContent content) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } builder.Clear(); builder.AppendHtml(content); return(builder); }
/// <inheritdoc /> public override void Write(IHtmlContent value) { if (value == null) { throw new ArgumentNullException(nameof(value)); } ContentBuilder.AppendHtml(value); }
/// <inheritdoc /> IHtmlContentBuilder IHtmlContentBuilder.AppendHtml(IHtmlContent content) { return(AppendHtml(content)); }
private void Verify(IHtmlContent html, string src, string alt) { var doc = new XmlDocument(); using (var writer = new StringWriter()) { html.WriteTo(writer, HtmlEncoder.Default); doc.LoadXml(writer.ToString()); } Assert.Equal(1, doc.ChildNodes.Count); var node = doc.ChildNodes.Item(0); Assert.Equal("img", node.Name); var srcNode = node.Attributes.GetNamedItem("src"); Assert.NotNull(srcNode); Assert.Equal("src", srcNode.Name); Assert.Equal(src, srcNode.Value); var altNode = node.Attributes.GetNamedItem("alt"); if (!string.IsNullOrWhiteSpace(alt)) { Assert.NotNull(altNode); Assert.Equal("alt", altNode.Name); Assert.Equal(alt, altNode.Value); } else { Assert.Null(altNode); } }
/// <summary> /// Sets the content. /// </summary> /// <param name="htmlContent">The <see cref="IHtmlContent"/> that replaces the content.</param> /// <returns>A reference to this instance after the set operation has completed.</returns> public TagHelperContent SetHtmlContent(IHtmlContent htmlContent) { HtmlContentBuilderExtensions.SetHtmlContent(this, htmlContent); return(this); }
/// <summary> /// Appends <paramref name="htmlContent"/> to the existing content. /// </summary> /// <param name="htmlContent">The <see cref="IHtmlContent"/> to be appended.</param> /// <returns>A reference to this instance after the append operation has completed.</returns> public abstract TagHelperContent AppendHtml(IHtmlContent htmlContent);
public PositionWrapper(IHtmlContent value, string position) { _value = value; Position = position; }
/// <summary> /// Initializes a new instance of <see cref="ViewBufferValue"/> with a <see cref="IHtmlContent"/> value. /// </summary> /// <param name="value">The <see cref="IHtmlContent"/>.</param> public ViewBufferValue(IHtmlContent content) { Value = content; }
/// <summary> /// Sets the body of the modal. /// </summary> /// <param name="body">Body content.</param> /// <returns>The modal builder instance.</returns> public MvcCoreBootstrapModalBuilder Body(IHtmlContent body) { return(this.SetConfigProp <MvcCoreBootstrapModalBuilder>(() => _config.BodyHtml = body)); }
public PositionWrapper(IHtmlContent value, string position) { _value = value.ToString(); Position = position; }
/// <inheritdoc /> public override void Write(IHtmlContent value) { var htmlTextWriter = TargetWriter as HtmlTextWriter; if (htmlTextWriter == null) { value.WriteTo(TargetWriter, HtmlEncoder); } else { htmlTextWriter.Write(value); } }
/// <summary> /// Sets the content to the <see cref="IHtmlContent"/> value. /// </summary> /// <param name="builder">The <see cref="IHtmlContentBuilder"/>.</param> /// <param name="content">The <see cref="IHtmlContent"/> value that replaces the content.</param> /// <returns>The <see cref="IHtmlContentBuilder"/>.</returns> public static IHtmlContentBuilder SetContent(this IHtmlContentBuilder builder, IHtmlContent content) { builder.Clear(); builder.Append(content); return builder; }
/// <summary> /// Appends an <see cref="Environment.NewLine"/> after appending the <see cref="IHtmlContent"/> value. /// </summary> /// <param name="builder">The <see cref="IHtmlContentBuilder"/>.</param> /// <param name="content">The <see cref="IHtmlContent"/> to append.</param> /// <returns>The <see cref="IHtmlContentBuilder"/>.</returns> public static IHtmlContentBuilder AppendLine(this IHtmlContentBuilder builder, IHtmlContent content) { builder.Append(content); builder.Append(HtmlEncodedString.NewLine); return builder; }
public IHtmlContentBuilder Append(IHtmlContent content) { Entries.Add(content); return this; }
private static string HtmlContentToString(IHtmlContent content) { using (var writer = new StringWriter()) { content.WriteTo(writer, new CommonTestEncoder()); return writer.ToString(); } }
public IHtmlContent GenerateTitle() { if (_title != null) { return _title; } if (_titleSeparator == null) { _titleSeparator = new HtmlString(" - "); } _titleParts.Sort(FlatPositionComparer.Instance); var htmlContentBuilder = new HtmlContentBuilder(); if (_titleParts.Count == 0) { return HtmlString.Empty; } for (var i = 0; i < _titleParts.Count; i++) { htmlContentBuilder.AppendHtml(_titleParts[i].Value); if (i < _titleParts.Count - 1) { htmlContentBuilder.AppendHtml(_titleSeparator); } } _title = htmlContentBuilder; return _title; }