Пример #1
0
 /// <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="selfClosing">
 /// <see cref="bool"/> indicating whether or not the tag in the Razor source was self-closing.
 /// </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,
     bool selfClosing,
     SourceLocation start,
     IList<KeyValuePair<string, SyntaxTreeNode>> attributes,
     IEnumerable<TagHelperDescriptor> descriptors)
 {
     TagName = tagName;
     SelfClosing = selfClosing;
     Start = start;
     Descriptors = descriptors;
     Attributes = new List<KeyValuePair<string, SyntaxTreeNode>>(attributes);
     Type = BlockType.Tag;
     ChunkGenerator = new TagHelperChunkGenerator(descriptors);
 }
Пример #2
0
        // Internal for testing
        internal TagHelperBlockBuilder(
            string tagName,
            bool selfClosing,
            IList<KeyValuePair<string, SyntaxTreeNode>> attributes,
            IEnumerable<SyntaxTreeNode> children)
        {
            TagName = tagName;
            SelfClosing = selfClosing;
            Attributes = attributes;
            Type = BlockType.Tag;
            ChunkGenerator = new TagHelperChunkGenerator(tagHelperDescriptors: null);

            // Children is IList, no AddRange
            foreach (var child in children)
            {
                Children.Add(child);
            }
        }