Merge branch 'htmlcontentpart1' into dev

This commit is contained in:
sornaks 2015-07-10 15:45:48 -07:00
commit ec5d1b4f4a
5 changed files with 59 additions and 21 deletions

View File

@ -3,7 +3,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using Microsoft.Framework.Internal; using Microsoft.Framework.Internal;
using Microsoft.Framework.WebEncoders;
namespace Microsoft.AspNet.Razor.Runtime.TagHelpers 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. // can use this to iterate through the values of the buffer.
return _buffer.GetEnumerator(); return _buffer.GetEnumerator();
} }
/// <inheritdoc />
public override void WriteTo(TextWriter writer, IHtmlEncoder encoder)
{
foreach (var entry in _buffer)
{
writer.Write(entry);
}
}
} }
} }

View File

@ -4,13 +4,16 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using Microsoft.AspNet.Html.Abstractions;
using Microsoft.Framework.WebEncoders;
namespace Microsoft.AspNet.Razor.Runtime.TagHelpers namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
{ {
/// <summary> /// <summary>
/// Abstract class used to buffer content returned by <see cref="ITagHelper"/>s. /// Abstract class used to buffer content returned by <see cref="ITagHelper"/>s.
/// </summary> /// </summary>
public abstract class TagHelperContent : IEnumerable<string> public abstract class TagHelperContent : IEnumerable<string>, IHtmlContent
{ {
/// <summary> /// <summary>
/// Gets a value indicating whether the content was modifed. /// Gets a value indicating whether the content was modifed.
@ -191,5 +194,8 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
{ {
return GetEnumerator(); return GetEnumerator();
} }
/// <inheritdoc />
public abstract void WriteTo(TextWriter writer, IHtmlEncoder encoder);
} }
} }

View File

@ -6,6 +6,7 @@
"url": "git://github.com/aspnet/razor" "url": "git://github.com/aspnet/razor"
}, },
"dependencies": { "dependencies": {
"Microsoft.AspNet.Html.Abstractions": "1.0.0-*",
"Microsoft.AspNet.Razor": "4.0.0-*", "Microsoft.AspNet.Razor": "4.0.0-*",
"Microsoft.Framework.BufferEntryCollection.Sources": { "type": "build", "version": "1.0.0-*" }, "Microsoft.Framework.BufferEntryCollection.Sources": { "type": "build", "version": "1.0.0-*" },
"Microsoft.Framework.ClosedGenericMatcher.Sources": { "type": "build", "version": "1.0.0-*" }, "Microsoft.Framework.ClosedGenericMatcher.Sources": { "type": "build", "version": "1.0.0-*" },

View File

@ -3,8 +3,11 @@
using System; using System;
using System.Globalization; using System.Globalization;
using System.IO;
using System.Linq; using System.Linq;
using Microsoft.AspNet.Testing; using Microsoft.AspNet.Testing;
using Microsoft.Framework.WebEncoders;
using Microsoft.Framework.WebEncoders.Testing;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Razor.Runtime.TagHelpers namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
@ -622,5 +625,21 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
// Assert // Assert
Assert.Equal(expected, tagHelperContent.GetContent()); 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());
}
} }
} }

View File

@ -1,24 +1,25 @@
{ {
"version": "1.0.0", "version": "1.0.0",
"dependencies": { "dependencies": {
"Microsoft.AspNet.Razor.Runtime": "4.0.0-*", "Microsoft.AspNet.Razor.Runtime": "4.0.0-*",
"Microsoft.AspNet.Testing": "1.0.0-*", "Microsoft.AspNet.Testing": "1.0.0-*",
"xunit.runner.aspnet": "2.0.0-aspnet-*" "Microsoft.Framework.WebEncoders.Testing": "1.0.0-*",
}, "xunit.runner.aspnet": "2.0.0-aspnet-*"
"commands": {
"test": "xunit.runner.aspnet"
},
"frameworks": {
"dnx451": {
"dependencies": {
"Moq": "4.2.1312.1622"
}
}, },
"dnxcore50": { "commands": {
"dependencies": { "test": "xunit.runner.aspnet"
"System.Reflection.TypeExtensions": "4.0.0-beta-*", },
"System.Runtime.Extensions": "4.0.10-beta-*" "frameworks": {
} "dnx451": {
"dependencies": {
"Moq": "4.2.1312.1622"
}
},
"dnxcore50": {
"dependencies": {
"System.Reflection.TypeExtensions": "4.0.0-beta-*",
"System.Runtime.Extensions": "4.0.10-beta-*"
}
}
} }
}
} }