/// <summary> /// Instantiates a new <see cref="ServiceFilterAttribute"/> instance. /// </summary> /// <param name="type">The <see cref="Type"/> of filter to find.</param> public ServiceFilterAttribute(Type type) { ServiceType = type ?? throw new ArgumentNullException(nameof(type)); }
public class TypeSafeServiceFilterAttribute<T> : ServiceFilterAttribute where T: IActionFilter { public TypeSafeServiceFilterAttribute():base(typeof(T)) { } }
[Route("api/[controller]")] [ApiController] public class CoursesController : ControllerBase { [HttpGet] [TypeSafeServiceFilterAttribute<ExampleFilter>()] public IActionResult Get() { return Ok(); } }