Moving UTF8EncodingWithoutBOM.cs to Common and renaming it as Encodings.
This commit is contained in:
parent
b1c0792e8c
commit
720923a1a4
|
|
@ -3,11 +3,14 @@
|
|||
|
||||
using System.Text;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.Internal
|
||||
namespace Microsoft.AspNet.Mvc
|
||||
{
|
||||
public static class UTF8EncodingWithoutBOM
|
||||
internal static class Encodings
|
||||
{
|
||||
public static readonly Encoding Encoding
|
||||
= new UTF8Encoding(encoderShouldEmitUTF8Identifier: false);
|
||||
/// <summary>
|
||||
/// Returns UTF8 Encoding without BOM and throws on invalid bytes
|
||||
/// </summary>
|
||||
public static readonly Encoding UTF8EncodingWithoutBOM
|
||||
= new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true);
|
||||
}
|
||||
}
|
||||
|
|
@ -20,6 +20,7 @@
|
|||
<Content Include="project.json" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Encodings.cs" />
|
||||
<Compile Include="NotNullArgument.cs" />
|
||||
<Compile Include="PlatformHelper.cs" />
|
||||
<Compile Include="PropertyHelper.cs" />
|
||||
|
|
|
|||
|
|
@ -9,6 +9,10 @@
|
|||
},
|
||||
"configurations": {
|
||||
"net45": {},
|
||||
"k10": {}
|
||||
"k10": {
|
||||
"dependencies": {
|
||||
"System.Text.Encoding.Extensions": "4.0.10.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,7 +4,6 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Microsoft.AspNet.Mvc.Internal;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc
|
||||
|
|
@ -14,7 +13,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
private const int BufferSize = 1024;
|
||||
|
||||
private JsonSerializerSettings _jsonSerializerSettings;
|
||||
private Encoding _encoding = UTF8EncodingWithoutBOM.Encoding;
|
||||
private Encoding _encoding = Encodings.UTF8EncodingWithoutBOM;
|
||||
|
||||
public JsonResult([NotNull] object data)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc.Core;
|
||||
using Microsoft.AspNet.Mvc.Internal;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.Framework.DependencyInjection;
|
||||
|
||||
|
|
@ -33,7 +32,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
{
|
||||
context.HttpContext.Response.ContentType = "text/html; charset=utf-8";
|
||||
var wrappedStream = new StreamWrapper(context.HttpContext.Response.Body);
|
||||
var encoding = UTF8EncodingWithoutBOM.Encoding;
|
||||
var encoding = Encodings.UTF8EncodingWithoutBOM;
|
||||
using (var writer = new StreamWriter(wrappedStream, encoding, BufferSize, leaveOpen: true))
|
||||
{
|
||||
try
|
||||
|
|
|
|||
|
|
@ -139,7 +139,6 @@
|
|||
<Compile Include="IControllerFactory.cs" />
|
||||
<Compile Include="Injector.cs" />
|
||||
<Compile Include="Internal\TypeHelper.cs" />
|
||||
<Compile Include="Internal\UTF8EncodingWithoutBOM.cs" />
|
||||
<Compile Include="IUrlHelper.cs" />
|
||||
<Compile Include="JsonOutputFormatter.cs" />
|
||||
<Compile Include="MvcOptions.cs" />
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ using System.IO;
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Mvc.Internal;
|
||||
using Microsoft.AspNet.Routing;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
|
|
@ -64,7 +63,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test.ActionResults
|
|||
var actionContext = CreateMockActionContext(httpResponse);
|
||||
|
||||
var tempStream = new MemoryStream();
|
||||
using (var writer = new StreamWriter(tempStream, UTF8EncodingWithoutBOM.Encoding, 1024, leaveOpen: true))
|
||||
using (var writer = new StreamWriter(tempStream, Encodings.UTF8EncodingWithoutBOM, 1024, leaveOpen: true))
|
||||
{
|
||||
var formatter = new JsonOutputFormatter(JsonOutputFormatter.CreateDefaultSettings(), false);
|
||||
formatter.WriteObject(writer, nonStringValue);
|
||||
|
|
|
|||
Loading…
Reference in New Issue