SetContent->SetHtmlContent

This commit is contained in:
ryanbrandenburg 2016-03-25 16:15:58 -07:00
parent 5ddb17d2fe
commit 5fe284a486
7 changed files with 20 additions and 20 deletions

View File

@ -58,18 +58,18 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
{
throw new ArgumentNullException(nameof(output));
}
IHtmlContent content = null;
if (Enabled)
{
var key = GenerateKey(context);
MemoryCacheEntryOptions options;
while (content == null)
{
Task<IHtmlContent> result = null;
if (!MemoryCache.TryGetValue(key, out result))
{
var tokenSource = new CancellationTokenSource();
@ -81,13 +81,13 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
options.AddExpirationToken(new CancellationChangeToken(tokenSource.Token));
var tcs = new TaskCompletionSource<IHtmlContent>();
// The returned value is ignored, we only do this so that
// the compiler doesn't complain about the returned task
// not being awaited
var localTcs = MemoryCache.Set(key, tcs.Task, options);
try
try
{
// The entry is set instead of assigning a value to the
// task so that the expiration options are are not impacted
@ -137,7 +137,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
// Clear the contents of the "cache" element since we don't want to render it.
output.SuppressOutput();
output.Content.SetContent(content);
output.Content.SetHtmlContent(content);
}
// Internal for unit testing

View File

@ -35,12 +35,12 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
/// <param name="htmlEncoder">The <see cref="HtmlEncoder"/>.</param>
public DistributedCacheTagHelper(
IDistributedCacheTagHelperService distributedCacheService,
HtmlEncoder htmlEncoder)
HtmlEncoder htmlEncoder)
: base(htmlEncoder)
{
_distributedCacheService = distributedCacheService;
}
/// <summary>
/// Gets the <see cref="IMemoryCache"/> instance used to cache workers.
/// </summary>
@ -51,7 +51,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
/// </summary>
[HtmlAttributeName(NameAttributeName)]
public string Name { get; set; }
/// <inheritdoc />
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{
@ -85,9 +85,9 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
// Clear the contents of the "cache" element since we don't want to render it.
output.SuppressOutput();
output.Content.SetContent(content);
output.Content.SetHtmlContent(content);
}
// Internal for unit testing
internal DistributedCacheEntryOptions GetDistributedCacheEntryOptions()
{

View File

@ -82,11 +82,11 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
if (childContent.IsWhiteSpace)
{
// Provide default label text since there was nothing useful in the Razor source.
output.Content.SetContent(tagBuilder.InnerHtml);
output.Content.SetHtmlContent(tagBuilder.InnerHtml);
}
else
{
output.Content.SetContent(childContent);
output.Content.SetHtmlContent(childContent);
}
}
}

View File

@ -264,7 +264,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
{
// Only HrefInclude is specified. Don't render the original tag.
output.TagName = null;
output.Content.SetContent(HtmlString.Empty);
output.Content.SetHtmlContent(HtmlString.Empty);
}
}
@ -279,7 +279,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
BuildFallbackBlock(builder);
}
output.PostElement.SetContent(builder);
output.PostElement.SetHtmlContent(builder);
}
private void BuildGlobbedLinkTags(TagHelperAttributeList attributes, TagHelperContent builder)

View File

@ -263,7 +263,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
BuildFallbackBlock(output.Attributes, builder);
}
output.PostElement.SetContent(builder);
output.PostElement.SetHtmlContent(builder);
}
private void BuildGlobbedScriptTags(

View File

@ -71,7 +71,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
if (tagBuilder != null)
{
// Overwrite current Content to ensure expression result round-trips correctly.
output.Content.SetContent(tagBuilder.InnerHtml);
output.Content.SetHtmlContent(tagBuilder.InnerHtml);
output.MergeAttributes(tagBuilder);
}

View File

@ -86,11 +86,11 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
if (childContent.IsWhiteSpace)
{
// Provide default label text since there was nothing useful in the Razor source.
output.Content.SetContent(tagBuilder.InnerHtml);
output.Content.SetHtmlContent(tagBuilder.InnerHtml);
}
else
{
output.Content.SetContent(childContent);
output.Content.SetHtmlContent(childContent);
}
}
}