React to removal of BufferedHtmlContent
This commit is contained in:
parent
53dc4d73a4
commit
f6c7295f41
|
|
@ -2,13 +2,12 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.Encodings.Web;
|
using System.Text.Encodings.Web;
|
||||||
using Microsoft.AspNet.Html.Abstractions;
|
using Microsoft.AspNet.Html.Abstractions;
|
||||||
using Microsoft.AspNet.Razor.TagHelpers;
|
|
||||||
using Microsoft.Extensions.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Razor.TagHelpers
|
namespace Microsoft.AspNet.Razor.TagHelpers
|
||||||
{
|
{
|
||||||
|
|
@ -18,15 +17,15 @@ namespace Microsoft.AspNet.Razor.TagHelpers
|
||||||
[DebuggerDisplay("{DebuggerToString(),nq}")]
|
[DebuggerDisplay("{DebuggerToString(),nq}")]
|
||||||
public class DefaultTagHelperContent : TagHelperContent
|
public class DefaultTagHelperContent : TagHelperContent
|
||||||
{
|
{
|
||||||
private BufferedHtmlContent _buffer;
|
private List<object> _buffer;
|
||||||
|
|
||||||
private BufferedHtmlContent Buffer
|
private List<object> Buffer
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_buffer == null)
|
if (_buffer == null)
|
||||||
{
|
{
|
||||||
_buffer = new BufferedHtmlContent();
|
_buffer = new List<object>();
|
||||||
}
|
}
|
||||||
|
|
||||||
return _buffer;
|
return _buffer;
|
||||||
|
|
@ -49,7 +48,7 @@ namespace Microsoft.AspNet.Razor.TagHelpers
|
||||||
|
|
||||||
using (var writer = new EmptyOrWhiteSpaceWriter())
|
using (var writer = new EmptyOrWhiteSpaceWriter())
|
||||||
{
|
{
|
||||||
foreach (var entry in _buffer.Entries)
|
foreach (var entry in _buffer)
|
||||||
{
|
{
|
||||||
if (entry == null)
|
if (entry == null)
|
||||||
{
|
{
|
||||||
|
|
@ -91,7 +90,7 @@ namespace Microsoft.AspNet.Razor.TagHelpers
|
||||||
|
|
||||||
using (var writer = new EmptyOrWhiteSpaceWriter())
|
using (var writer = new EmptyOrWhiteSpaceWriter())
|
||||||
{
|
{
|
||||||
foreach (var entry in _buffer.Entries)
|
foreach (var entry in _buffer)
|
||||||
{
|
{
|
||||||
if (entry == null)
|
if (entry == null)
|
||||||
{
|
{
|
||||||
|
|
@ -124,21 +123,28 @@ namespace Microsoft.AspNet.Razor.TagHelpers
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override TagHelperContent Append(string unencoded)
|
public override TagHelperContent Append(string unencoded)
|
||||||
{
|
{
|
||||||
Buffer.Append(unencoded);
|
Buffer.Add(unencoded);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override TagHelperContent AppendHtml(string encoded)
|
public override TagHelperContent AppendHtml(string encoded)
|
||||||
{
|
{
|
||||||
Buffer.AppendHtml(encoded);
|
if (encoded == null)
|
||||||
|
{
|
||||||
|
Buffer.Add(null);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Buffer.Add(new HtmlEncodedString(encoded));
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override TagHelperContent Append(IHtmlContent htmlContent)
|
public override TagHelperContent Append(IHtmlContent htmlContent)
|
||||||
{
|
{
|
||||||
Buffer.Append(htmlContent);
|
Buffer.Add(htmlContent);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -183,7 +189,28 @@ namespace Microsoft.AspNet.Razor.TagHelpers
|
||||||
throw new ArgumentNullException(nameof(encoder));
|
throw new ArgumentNullException(nameof(encoder));
|
||||||
}
|
}
|
||||||
|
|
||||||
Buffer.WriteTo(writer, encoder);
|
if (_buffer == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var entry in _buffer)
|
||||||
|
{
|
||||||
|
if (entry == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var stringValue = entry as string;
|
||||||
|
if (stringValue != null)
|
||||||
|
{
|
||||||
|
encoder.Encode(writer, stringValue);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
((IHtmlContent)entry).WriteTo(writer, encoder);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private string DebuggerToString()
|
private string DebuggerToString()
|
||||||
|
|
|
||||||
|
|
@ -12,10 +12,6 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"Microsoft.AspNet.Html.Abstractions": "1.0.0-*",
|
"Microsoft.AspNet.Html.Abstractions": "1.0.0-*",
|
||||||
"Microsoft.AspNet.Razor": "4.0.0-*",
|
"Microsoft.AspNet.Razor": "4.0.0-*",
|
||||||
"Microsoft.Extensions.BufferedHtmlContent.Sources": {
|
|
||||||
"type": "build",
|
|
||||||
"version": "1.0.0-*"
|
|
||||||
},
|
|
||||||
"Microsoft.Extensions.ClosedGenericMatcher.Sources": {
|
"Microsoft.Extensions.ClosedGenericMatcher.Sources": {
|
||||||
"type": "build",
|
"type": "build",
|
||||||
"version": "1.0.0-*"
|
"version": "1.0.0-*"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue