I've got an API method where the Id parameter is annotated with CacheType attribute
public Object Get([CacheType(CacheTypes.Venue)]int Id)
{
....
}
Can I read the value of the parameter attribute inside of ActionFilterAttribute
public class CacheOutputAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(HttpActionContext actionContext)
{
//read CacheType value
}
}
To get the parameter value
actionContext.ActionArguments["id"]
To do something with the parameters that have CacheOutput
attribute
actionContext.ActionDescriptor.GetParameters().ToList().ForEach(p =>
{
var cacheOutput = p.GetCustomAttributes<CacheOutputAttribute>();
if (cacheOutput.Any())
{
// do something
}
});