Fix for #384 - And some other changes to controller as filter

This is a major change to how we handle the scenario where a controller is
a filter. We want to change the lifetime of the controller object, by
scoping it around action filters and result filters. This means that a
controller class can only implement action filters and result filters.

To implement #384 - we're creating a delegating filter class
'ControllerFilter' which will forward calls to the implementation of the
controller. This is discovered in the controller model and added to the
filter collection. This filter is removable as an opt-out of this feature.

The ControllerFilter only implements action filter and result filter, so
the new restriction about filter types on Controller is in place. A future
change will move the instantiation of the controller to after resource
filters.
This commit is contained in:
Ryan Nowak 2015-01-14 18:35:20 -08:00
parent 12c2759cec
commit e1069dbf65
1 changed files with 10 additions and 10 deletions

View File

@ -59,7 +59,7 @@ namespace Microsoft.AspNet.Mvc
{
return ActionContext?.RouteData;
}
}
}
public ModelStateDictionary ModelState
{
@ -113,7 +113,7 @@ namespace Microsoft.AspNet.Mvc
return _viewData;
}
set
{
{
if (value == null)
{
throw
@ -822,7 +822,7 @@ namespace Microsoft.AspNet.Mvc
}
/// <summary>
/// Updates the specified <paramref name="model"/> instance using values from the controller's current
/// Updates the specified <paramref name="model"/> instance using values from the controller's current
/// <see cref="IValueProvider"/> and a <paramref name="prefix"/>.
/// </summary>
/// <typeparam name="TModel">The type of the model object.</typeparam>
@ -847,7 +847,7 @@ namespace Microsoft.AspNet.Mvc
}
/// <summary>
/// Updates the specified <paramref name="model"/> instance using the <paramref name="valueProvider"/> and a
/// Updates the specified <paramref name="model"/> instance using the <paramref name="valueProvider"/> and a
/// <paramref name="prefix"/>.
/// </summary>
/// <typeparam name="TModel">The type of the model object.</typeparam>
@ -882,14 +882,14 @@ namespace Microsoft.AspNet.Mvc
}
/// <summary>
/// Updates the specified <paramref name="model"/> instance using values from the controller's current
/// Updates the specified <paramref name="model"/> instance using values from the controller's current
/// <see cref="IValueProvider"/> and a <paramref name="prefix"/>.
/// </summary>
/// <typeparam name="TModel">The type of the model object.</typeparam>
/// <param name="model">The model instance to update.</param>
/// <param name="prefix">The prefix to use when looking up values in the current <see cref="IValueProvider"/>.
/// </param>
/// <param name="includeExpressions"> <see cref="Expression"/>(s) which represent top-level properties
/// <param name="includeExpressions"> <see cref="Expression"/>(s) which represent top-level properties
/// which need to be included for the current model.</param>
/// <returns>A <see cref="Task"/> that on completion returns <c>true</c> if the update is successful</returns>
[NonAction]
@ -920,7 +920,7 @@ namespace Microsoft.AspNet.Mvc
}
/// <summary>
/// Updates the specified <paramref name="model"/> instance using values from the controller's current
/// Updates the specified <paramref name="model"/> instance using values from the controller's current
/// <see cref="IValueProvider"/> and a <paramref name="prefix"/>.
/// </summary>
/// <typeparam name="TModel">The type of the model object.</typeparam>
@ -957,7 +957,7 @@ namespace Microsoft.AspNet.Mvc
}
/// <summary>
/// Updates the specified <paramref name="model"/> instance using the <paramref name="valueProvider"/> and a
/// Updates the specified <paramref name="model"/> instance using the <paramref name="valueProvider"/> and a
/// <paramref name="prefix"/>.
/// </summary>
/// <typeparam name="TModel">The type of the model object.</typeparam>
@ -965,7 +965,7 @@ namespace Microsoft.AspNet.Mvc
/// <param name="prefix">The prefix to use when looking up values in the <paramref name="valueProvider"/>
/// </param>
/// <param name="valueProvider">The <see cref="IValueProvider"/> used for looking up values.</param>
/// <param name="includeExpressions"> <see cref="Expression"/>(s) which represent top-level properties
/// <param name="includeExpressions"> <see cref="Expression"/>(s) which represent top-level properties
/// which need to be included for the current model.</param>
/// <returns>A <see cref="Task"/> that on completion returns <c>true</c> if the update is successful</returns>
[NonAction]
@ -997,7 +997,7 @@ namespace Microsoft.AspNet.Mvc
}
/// <summary>
/// Updates the specified <paramref name="model"/> instance using the <paramref name="valueProvider"/> and a
/// Updates the specified <paramref name="model"/> instance using the <paramref name="valueProvider"/> and a
/// <paramref name="prefix"/>.
/// </summary>
/// <typeparam name="TModel">The type of the model object.</typeparam>