diff --git a/src/Microsoft.AspNet.Mvc.Core/ActionDescriptor.cs b/src/Microsoft.AspNet.Mvc.Core/ActionDescriptor.cs index c6a1b80cc1..2f1895fa1d 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ActionDescriptor.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ActionDescriptor.cs @@ -17,5 +17,7 @@ namespace Microsoft.AspNet.Mvc public List DynamicConstraints { get; set; } public List Parameters { get; set; } + + public List Filters { get; set; } } } diff --git a/src/Microsoft.AspNet.Mvc.Core/Filters/ActionFilterContext.cs b/src/Microsoft.AspNet.Mvc.Core/Filters/ActionFilterContext.cs new file mode 100644 index 0000000000..a5508cece3 --- /dev/null +++ b/src/Microsoft.AspNet.Mvc.Core/Filters/ActionFilterContext.cs @@ -0,0 +1,19 @@ +using System.Collections.Generic; + +namespace Microsoft.AspNet.Mvc +{ + public class ActionFilterContext + { + public ActionFilterContext(ActionContext actionContext, IDictionary actionParameters) + { + ActionContext = actionContext; + ActionParameters = actionParameters; + } + + public virtual IDictionary ActionParameters { get; private set; } + + public virtual ActionContext ActionContext { get; private set; } + + public virtual IActionResult Result { get; set; } + } +} diff --git a/src/Microsoft.AspNet.Mvc.Core/Filters/ActionResultFilterContext.cs b/src/Microsoft.AspNet.Mvc.Core/Filters/ActionResultFilterContext.cs new file mode 100644 index 0000000000..1ab9bedb64 --- /dev/null +++ b/src/Microsoft.AspNet.Mvc.Core/Filters/ActionResultFilterContext.cs @@ -0,0 +1,14 @@ +namespace Microsoft.AspNet.Mvc +{ + public class ActionResultFilterContext + { + public ActionResultFilterContext(ActionContext actionContext) + { + ActionContext = actionContext; + } + + public ActionContext ActionContext { get; private set; } + + public IActionResult Result { get; set; } + } +} diff --git a/src/Microsoft.AspNet.Mvc.Core/Filters/AuthorizationFilterContext.cs b/src/Microsoft.AspNet.Mvc.Core/Filters/AuthorizationFilterContext.cs new file mode 100644 index 0000000000..afdce78c66 --- /dev/null +++ b/src/Microsoft.AspNet.Mvc.Core/Filters/AuthorizationFilterContext.cs @@ -0,0 +1,39 @@ +namespace Microsoft.AspNet.Mvc +{ + public class AuthorizationFilterContext + { + private IActionResult _actionResult; + private bool _fail; + + public AuthorizationFilterContext(ActionContext actionContext) + { + ActionContext = actionContext; + } + + public bool HasFailed + { + get { return _fail; } + } + + public ActionContext ActionContext { get; private set; } + + public IActionResult ActionResult + { + get { return _actionResult; } + set + { + if (value != null) + { + Fail(); + } + + _actionResult = value; + } + } + + public void Fail() + { + _fail = true; + } + } +} diff --git a/src/Microsoft.AspNet.Mvc.Core/Filters/ExceptionFilterContext.cs b/src/Microsoft.AspNet.Mvc.Core/Filters/ExceptionFilterContext.cs new file mode 100644 index 0000000000..8beab4563d --- /dev/null +++ b/src/Microsoft.AspNet.Mvc.Core/Filters/ExceptionFilterContext.cs @@ -0,0 +1,20 @@ +using System; + +namespace Microsoft.AspNet.Mvc +{ + public class ExceptionFilterContext + { + public ExceptionFilterContext(ActionContext actionContext, Exception exception) + { + ActionContext = actionContext; + Exception = exception; + } + + // TODO: Should we let the exception mutate in the pipeline. MVC lets you do that. + public virtual Exception Exception { get; set; } + + public virtual ActionContext ActionContext { get; private set; } + + public virtual IActionResult Result { get; set; } + } +} diff --git a/src/Microsoft.AspNet.Mvc.Core/Filters/IFilter.cs b/src/Microsoft.AspNet.Mvc.Core/Filters/IFilter.cs new file mode 100644 index 0000000000..0622bf727c --- /dev/null +++ b/src/Microsoft.AspNet.Mvc.Core/Filters/IFilter.cs @@ -0,0 +1,7 @@ +namespace Microsoft.AspNet.Mvc +{ + public interface IFilter + { + // Marker only interface to any IFilter gets picked up by the DefaultActionDescriptorProvider + } +} \ No newline at end of file