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.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Primitives;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Formatters
|
||||
|
|
@ -11,6 +12,39 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
|
|||
/// </summary>
|
||||
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>
|
||||
/// Gets or sets the content type to write to the response.
|
||||
/// </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="object">The object to write to the response.</param>
|
||||
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)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(writerFactory));
|
||||
}
|
||||
|
||||
HttpContext = httpContext;
|
||||
WriterFactory = writerFactory;
|
||||
ObjectType = objectType;
|
||||
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>
|
||||
/// Gets or sets a delegate used to create a <see cref="TextWriter"/> for writing the response.
|
||||
/// </summary>
|
||||
|
|
|
|||
Loading…
Reference in New Issue