Exemplo n.º 1
0
        internal override void WriteImpl(ref HtmlEncodingTextWriter writer)
        {
            writer.WriteRaw('<');

            if (_shouldEncodeName)
            {
                writer.Write(_tagName);
            }
            else
            {
                writer.WriteRaw(_tagName);
            }

            foreach (var attr in _attributes)
            {
                writer.WriteRaw(' ');
                attr.Write(ref writer);
            }

            writer.WriteRaw('>');

            foreach (var child in _children)
            {
                child.WriteImpl(ref writer);
            }

            writer.WriteRaw("</");
            writer.Write(_tagName);
            writer.WriteRaw('>');
        }
Exemplo n.º 2
0
 internal override void WriteImpl(ref HtmlEncodingTextWriter writer)
 {
     foreach (var child in _children)
     {
         child.WriteImpl(ref writer);
     }
 }
Exemplo n.º 3
0
        internal override void WriteImpl(ref HtmlEncodingTextWriter writer)
        {
            var builder = _builderFactory();

            if (builder == null)
            {
                throw new InvalidOperationException("Builder factory cannot return null");
            }
            builder.WritePartial(ref writer);
        }
Exemplo n.º 4
0
        internal override void WriteImpl(ref HtmlEncodingTextWriter writer)
        {
            writer.WriteRaw('<');

            if (_shouldEncodeName)
            {
                writer.Write(_name);
            }
            else
            {
                writer.WriteRaw(_name);
            }

            foreach (var attr in _attributes)
            {
                writer.WriteRaw(' ');
                attr.Write(ref writer);
            }

            writer.WriteRaw("/>");
        }
Exemplo n.º 5
0
        /// <summary>
        /// Write the HTML to a <see cref="TextWriter"/>, using an <see cref="HtmlEncoder"/> to encode input text
        /// </summary>
        /// <param name="writer">The writer</param>
        /// <param name="htmlEncoder">The HTML encoder</param>
        public unsafe void Write(TextWriter writer, HtmlEncoder htmlEncoder)
        {
            if (writer == null)
            {
                throw new ArgumentNullException(nameof(writer));
            }
            if (htmlEncoder == null)
            {
                throw new ArgumentNullException(nameof(htmlEncoder));
            }

            var buffer = ArrayPool <char> .Shared.Rent(4096);

            fixed(char *start = buffer)
            {
                var htmlEncodingTextWriter = new HtmlEncodingTextWriter(writer, htmlEncoder, buffer, start, buffer.Length);

                WriteImpl(ref htmlEncodingTextWriter);
                htmlEncodingTextWriter.Flush();
            }

            ArrayPool <char> .Shared.Return(buffer);
        }
Exemplo n.º 6
0
 internal void Write(ref HtmlEncodingTextWriter writer)
 {
     if (_shouldEncode)
     {
         writer.Write(_name);
         if (_value != null)
         {
             writer.WriteRaw("=\"");
             writer.Write(_value);
             writer.WriteRaw('"');
         }
     }
     else
     {
         writer.WriteRaw(_name);
         if (_value != null)
         {
             writer.WriteRaw("=\"");
             writer.WriteRaw(_value);
             writer.WriteRaw('"');
         }
     }
 }
Exemplo n.º 7
0
 internal abstract void WriteImpl(ref HtmlEncodingTextWriter writer);
Exemplo n.º 8
0
 internal override void WriteImpl(ref HtmlEncodingTextWriter writer)
 {
     writer.Write(_text);
 }
Exemplo n.º 9
0
 internal override void WriteImpl(ref HtmlEncodingTextWriter writer)
 {
     writer.WriteRaw(_rawHtml);
 }