Context + ActionDescriptor + IFilter marker

This commit is contained in:
Yishai Galatzer 2014-03-03 00:32:53 -08:00
parent 318c19b2f9
commit dc6b1b1a4a
6 changed files with 101 additions and 0 deletions

View File

@ -17,5 +17,7 @@ namespace Microsoft.AspNet.Mvc
public List<IActionConstraint> DynamicConstraints { get; set; }
public List<ParameterDescriptor> Parameters { get; set; }
public List<IFilter> Filters { get; set; }
}
}

View File

@ -0,0 +1,19 @@
using System.Collections.Generic;
namespace Microsoft.AspNet.Mvc
{
public class ActionFilterContext
{
public ActionFilterContext(ActionContext actionContext, IDictionary<string, object> actionParameters)
{
ActionContext = actionContext;
ActionParameters = actionParameters;
}
public virtual IDictionary<string, object> ActionParameters { get; private set; }
public virtual ActionContext ActionContext { get; private set; }
public virtual IActionResult Result { get; set; }
}
}

View File

@ -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; }
}
}

View File

@ -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;
}
}
}

View File

@ -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; }
}
}

View File

@ -0,0 +1,7 @@
namespace Microsoft.AspNet.Mvc
{
public interface IFilter
{
// Marker only interface to any IFilter gets picked up by the DefaultActionDescriptorProvider
}
}