Merge branch 'htmlcontentpart1' into dev
This commit is contained in:
commit
ec5d1b4f4a
|
|
@ -3,7 +3,9 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Microsoft.Framework.Internal;
|
||||
using Microsoft.Framework.WebEncoders;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
|
||||
{
|
||||
|
|
@ -208,5 +210,14 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
|
|||
// can use this to iterate through the values of the buffer.
|
||||
return _buffer.GetEnumerator();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void WriteTo(TextWriter writer, IHtmlEncoder encoder)
|
||||
{
|
||||
foreach (var entry in _buffer)
|
||||
{
|
||||
writer.Write(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,13 +4,16 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Microsoft.AspNet.Html.Abstractions;
|
||||
using Microsoft.Framework.WebEncoders;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Abstract class used to buffer content returned by <see cref="ITagHelper"/>s.
|
||||
/// </summary>
|
||||
public abstract class TagHelperContent : IEnumerable<string>
|
||||
public abstract class TagHelperContent : IEnumerable<string>, IHtmlContent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the content was modifed.
|
||||
|
|
@ -191,5 +194,8 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
|
|||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public abstract void WriteTo(TextWriter writer, IHtmlEncoder encoder);
|
||||
}
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@
|
|||
"url": "git://github.com/aspnet/razor"
|
||||
},
|
||||
"dependencies": {
|
||||
"Microsoft.AspNet.Html.Abstractions": "1.0.0-*",
|
||||
"Microsoft.AspNet.Razor": "4.0.0-*",
|
||||
"Microsoft.Framework.BufferEntryCollection.Sources": { "type": "build", "version": "1.0.0-*" },
|
||||
"Microsoft.Framework.ClosedGenericMatcher.Sources": { "type": "build", "version": "1.0.0-*" },
|
||||
|
|
|
|||
|
|
@ -3,8 +3,11 @@
|
|||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNet.Testing;
|
||||
using Microsoft.Framework.WebEncoders;
|
||||
using Microsoft.Framework.WebEncoders.Testing;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
|
||||
|
|
@ -622,5 +625,21 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
|
|||
// Assert
|
||||
Assert.Equal(expected, tagHelperContent.GetContent());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WriteTo_WritesToATextWriter()
|
||||
{
|
||||
// Arrange
|
||||
var tagHelperContent = new DefaultTagHelperContent();
|
||||
var writer = new StringWriter();
|
||||
tagHelperContent.SetContent("Hello ");
|
||||
tagHelperContent.Append("World");
|
||||
|
||||
// Act
|
||||
tagHelperContent.WriteTo(writer, new CommonTestEncoder());
|
||||
|
||||
// Assert
|
||||
Assert.Equal("Hello World", writer.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,24 +1,25 @@
|
|||
{
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"Microsoft.AspNet.Razor.Runtime": "4.0.0-*",
|
||||
"Microsoft.AspNet.Testing": "1.0.0-*",
|
||||
"xunit.runner.aspnet": "2.0.0-aspnet-*"
|
||||
},
|
||||
"commands": {
|
||||
"test": "xunit.runner.aspnet"
|
||||
},
|
||||
"frameworks": {
|
||||
"dnx451": {
|
||||
"dependencies": {
|
||||
"Moq": "4.2.1312.1622"
|
||||
}
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"Microsoft.AspNet.Razor.Runtime": "4.0.0-*",
|
||||
"Microsoft.AspNet.Testing": "1.0.0-*",
|
||||
"Microsoft.Framework.WebEncoders.Testing": "1.0.0-*",
|
||||
"xunit.runner.aspnet": "2.0.0-aspnet-*"
|
||||
},
|
||||
"dnxcore50": {
|
||||
"dependencies": {
|
||||
"System.Reflection.TypeExtensions": "4.0.0-beta-*",
|
||||
"System.Runtime.Extensions": "4.0.10-beta-*"
|
||||
}
|
||||
"commands": {
|
||||
"test": "xunit.runner.aspnet"
|
||||
},
|
||||
"frameworks": {
|
||||
"dnx451": {
|
||||
"dependencies": {
|
||||
"Moq": "4.2.1312.1622"
|
||||
}
|
||||
},
|
||||
"dnxcore50": {
|
||||
"dependencies": {
|
||||
"System.Reflection.TypeExtensions": "4.0.0-beta-*",
|
||||
"System.Runtime.Extensions": "4.0.10-beta-*"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue