Move HttpContext property up a level
This commit is contained in:
parent
261f73abc7
commit
8fb339483d
|
|
@ -2,6 +2,7 @@
|
||||||
// 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 Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.Extensions.Primitives;
|
using Microsoft.Extensions.Primitives;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Mvc.Formatters
|
namespace Microsoft.AspNetCore.Mvc.Formatters
|
||||||
|
|
@ -11,6 +12,39 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class OutputFormatterCanWriteContext
|
public abstract class OutputFormatterCanWriteContext
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// <para>
|
||||||
|
/// This constructor is obsolete and will be removed in a future version.
|
||||||
|
/// Please use <see cref="OutputFormatterCanWriteContext(Http.HttpContext)"/> instead.
|
||||||
|
/// </para>
|
||||||
|
/// <para>
|
||||||
|
/// Creates a new <see cref="OutputFormatterCanWriteContext"/>.
|
||||||
|
/// </para>
|
||||||
|
/// </summary>
|
||||||
|
[Obsolete("This constructor is obsolete and will be removed in a future version. Please use the constructor taking a HttpContext instead.")]
|
||||||
|
protected OutputFormatterCanWriteContext()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new <see cref="OutputFormatterCanWriteContext"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="httpContext">The <see cref="HttpContext"/> for the current request.</param>
|
||||||
|
protected OutputFormatterCanWriteContext(HttpContext httpContext)
|
||||||
|
{
|
||||||
|
if (httpContext == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(httpContext));
|
||||||
|
}
|
||||||
|
|
||||||
|
HttpContext = httpContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the <see cref="HttpContext"/> context associated with the current operation.
|
||||||
|
/// </summary>
|
||||||
|
public virtual HttpContext HttpContext { get; protected set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the content type to write to the response.
|
/// Gets or sets the content type to write to the response.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -21,28 +21,18 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
|
||||||
/// <param name="objectType">The <see cref="Type"/> of the object to write to the response.</param>
|
/// <param name="objectType">The <see cref="Type"/> of the object to write to the response.</param>
|
||||||
/// <param name="object">The object to write to the response.</param>
|
/// <param name="object">The object to write to the response.</param>
|
||||||
public OutputFormatterWriteContext(HttpContext httpContext, Func<Stream, Encoding, TextWriter> writerFactory, Type objectType, object @object)
|
public OutputFormatterWriteContext(HttpContext httpContext, Func<Stream, Encoding, TextWriter> writerFactory, Type objectType, object @object)
|
||||||
|
: base(httpContext)
|
||||||
{
|
{
|
||||||
if (httpContext == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(httpContext));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (writerFactory == null)
|
if (writerFactory == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(writerFactory));
|
throw new ArgumentNullException(nameof(writerFactory));
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpContext = httpContext;
|
|
||||||
WriterFactory = writerFactory;
|
WriterFactory = writerFactory;
|
||||||
ObjectType = objectType;
|
ObjectType = objectType;
|
||||||
Object = @object;
|
Object = @object;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the <see cref="HttpContext"/> context associated with the current operation.
|
|
||||||
/// </summary>
|
|
||||||
public virtual HttpContext HttpContext { get; protected set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a delegate used to create a <see cref="TextWriter"/> for writing the response.
|
/// Gets or sets a delegate used to create a <see cref="TextWriter"/> for writing the response.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue