示例#1
0
        internal async Task WriteAsync(AsyncHtmlEncodingTextWriter writer)
        {
            if (_shouldEncode)
            {
                await writer.Write(_name).ConfigureAwait(false);

                if (_value != null)
                {
                    await writer.WriteRaw("=\"").ConfigureAwait(false);

                    await writer.Write(_value).ConfigureAwait(false);

                    await writer.WriteRaw('"').ConfigureAwait(false);
                }
            }
            else
            {
                await writer.WriteRaw(_name).ConfigureAwait(false);

                if (_value != null)
                {
                    await writer.WriteRaw("=\"").ConfigureAwait(false);

                    await writer.WriteRaw(_value).ConfigureAwait(false);

                    await writer.WriteRaw('"').ConfigureAwait(false);
                }
            }
        }
示例#2
0
文件: Tag.cs 项目: raihansazal/Eighty
        internal override async Task WriteAsyncImpl(AsyncHtmlEncodingTextWriter writer)
        {
            await writer.WriteRaw('<').ConfigureAwait(false);

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

            foreach (var attr in _attributes)
            {
                await writer.WriteRaw(' ').ConfigureAwait(false);

                await attr.WriteAsync(writer).ConfigureAwait(false);
            }

            await writer.WriteRaw('>').ConfigureAwait(false);

            foreach (var child in _children)
            {
                await child.WriteAsyncImpl(writer).ConfigureAwait(false);
            }

            await writer.WriteRaw("</").ConfigureAwait(false);

            await writer.Write(_tagName).ConfigureAwait(false);

            await writer.WriteRaw('>').ConfigureAwait(false);
        }
示例#3
0
 internal override async Task WriteAsyncImpl(AsyncHtmlEncodingTextWriter writer)
 {
     foreach (var child in _children)
     {
         await child.WriteAsyncImpl(writer).ConfigureAwait(false);
     }
 }
示例#4
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>
        /// <exception cref="InvalidOperationException">Thrown if <see cref="CanWriteAsync"/> is false (ie if this <see cref="Html"/> contains an <see cref="HtmlBuilder"/>.</exception>
        public async Task WriteAsync(TextWriter writer, HtmlEncoder htmlEncoder)
        {
            if (writer == null)
            {
                throw new ArgumentNullException(nameof(writer));
            }
            if (htmlEncoder == null)
            {
                throw new ArgumentNullException(nameof(htmlEncoder));
            }
            if (!CanWriteAsync)
            {
                throw new InvalidOperationException("Can't write this HTML asynchronously because it contains an HtmlBuilder");
            }

            var htmlEncodingTextWriter = new AsyncHtmlEncodingTextWriter(writer, htmlEncoder);

            await WriteAsyncImpl(htmlEncodingTextWriter).ConfigureAwait(false);

            await htmlEncodingTextWriter.FlushAndClear().ConfigureAwait(false);
        }
示例#5
0
 internal override Task WriteAsyncImpl(AsyncHtmlEncodingTextWriter writer)
 {
     throw new InvalidOperationException("Can't run an HtmlBuilder asynchronously");
 }
示例#6
0
 internal abstract Task WriteAsyncImpl(AsyncHtmlEncodingTextWriter writer);
示例#7
0
 internal override Task WriteAsyncImpl(AsyncHtmlEncodingTextWriter writer)
 => writer.Write(_text);
示例#8
0
文件: Raw.cs 项目: raihansazal/Eighty
 internal override Task WriteAsyncImpl(AsyncHtmlEncodingTextWriter writer)
 => writer.WriteRaw(_rawHtml);