/// <summary> /// Instantiates a new instance of the <see cref="TagHelperBlockBuilder"/> class /// with the provided <paramref name="tagName"/> and derives its <see cref="Attributes"/> /// and <see cref="BlockBuilder.Type"/> from the <paramref name="startTag"/>. /// </summary> /// <param name="tagName">An HTML tag name.</param> /// <param name="descriptors">The <see cref="TagHelperDescriptor"/>s associated with the current HTML /// tag.</param> /// <param name="startTag">The <see cref="Block"/> that contains all information about the start /// of the HTML element.</param> public TagHelperBlockBuilder(string tagName, IEnumerable <TagHelperDescriptor> descriptors, Block startTag) { TagName = tagName; CodeGenerator = new TagHelperCodeGenerator(descriptors); Type = startTag.Type; Attributes = GetTagAttributes(startTag); // There will always be at least one child for the '<'. Start = startTag.Children.First().Start; }
/// <summary> /// Instantiates a new instance of the <see cref="TagHelperBlockBuilder"/> class /// with the provided <paramref name="tagName"/> and derives its <see cref="Attributes"/> /// and <see cref="BlockBuilder.Type"/> from the <paramref name="startTag"/>. /// </summary> /// <param name="tagName">An HTML tag name.</param> /// <param name="start">Starting location of the <see cref="TagHelperBlock"/>.</param> /// <param name="attributes">Attributes of the <see cref="TagHelperBlock"/>.</param> /// <param name="descriptors">The <see cref="TagHelperDescriptor"/>s associated with the current HTML /// tag.</param> public TagHelperBlockBuilder(string tagName, SourceLocation start, IDictionary <string, SyntaxTreeNode> attributes, IEnumerable <TagHelperDescriptor> descriptors) { TagName = tagName; Start = start; Descriptors = descriptors; Type = BlockType.Tag; CodeGenerator = new TagHelperCodeGenerator(descriptors); Attributes = new Dictionary <string, SyntaxTreeNode>(attributes); }
// Internal for testing internal TagHelperBlockBuilder(string tagName, IDictionary <string, SyntaxTreeNode> attributes, IEnumerable <SyntaxTreeNode> children) { TagName = tagName; Attributes = attributes; Type = BlockType.Tag; CodeGenerator = new TagHelperCodeGenerator(tagHelperDescriptors: null); // Children is IList, no AddRange foreach (var child in children) { Children.Add(child); } }