Remove long form Dispose

Fixes #3834
This commit is contained in:
Pranav K 2015-12-30 18:54:06 -08:00
parent 7d5a68b9ae
commit 2f66c041fd
3 changed files with 21 additions and 22 deletions

View File

@ -343,11 +343,7 @@ namespace Microsoft.AspNet.Mvc
}
/// <inheritdoc />
public void Dispose()
{
Dispose(disposing: true);
GC.SuppressFinalize(this);
}
public void Dispose() => Dispose(disposing: true);
/// <summary>
/// Releases all resources currently used by this <see cref="Controller"/> instance.

View File

@ -8,11 +8,18 @@ using Microsoft.Extensions.DependencyInjection;
namespace Microsoft.AspNet.Mvc.Rendering
{
/// <summary>
/// An HTML form element in an MVC view.
/// </summary>
public class MvcForm : IDisposable
{
private readonly ViewContext _viewContext;
private bool _disposed;
/// <summary>
/// Initializes a new instance of <see cref="MvcForm"/>.
/// </summary>
/// <param name="viewContext">The <see cref="ViewContext"/>.</param>
public MvcForm(ViewContext viewContext)
{
if (viewContext == null)
@ -23,10 +30,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
_viewContext = viewContext;
}
/// <inheritdoc />
public void Dispose()
{
Dispose(disposing: true);
GC.SuppressFinalize(this);
if (!_disposed)
{
_disposed = true;
GenerateEndForm();
}
}
/// <summary>
@ -34,9 +45,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// </summary>
public void EndForm()
{
Dispose(disposing: true);
Dispose();
}
/// <summary>
/// Renders <see cref="ViewFeatures.FormContext.EndOfFormContent"/> and
/// the &lt;/form&gt;.
/// </summary>
protected virtual void GenerateEndForm()
{
RenderEndOfFormContent();
@ -44,15 +59,6 @@ namespace Microsoft.AspNet.Mvc.Rendering
_viewContext.FormContext = null;
}
protected virtual void Dispose(bool disposing)
{
if (!_disposed)
{
_disposed = true;
GenerateEndForm();
}
}
private void RenderEndOfFormContent()
{
var formContext = _viewContext.FormContext;

View File

@ -544,11 +544,8 @@ namespace System.Web.Http
return new HttpStatusCodeResult((int)status);
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
/// <inheritdoc />
public void Dispose() => Dispose(disposing: true);
/// <summary>
/// Validates the given entity and adds the validation errors to the <see cref="ApiController.ModelState"/>