在类库项目中使用ActionFilterAttribute(.NET)

在类库项目中使用ActionFilterAttribute(.NET)

问题描述:

我想通过'类库'类方法使用'WEB API'操作过滤器属性。那可能吗?或者有什么建议?在类库项目中使用ActionFilterAttribute(.NET)

不是没有比它的价值更多的麻烦。动作过滤器是Web Api的一项功能,因此除非您正在讨论将Web Api控制器放入您自己的库中,或者在Web Api控制器中使用库中的过滤器,否则您将无法直接利用它们。

一个潜在的解决方案可能是使用proxy patterndecorator pattern来为您的库处理cross-cutting concerns。详情请看Aspect-Oriented Programming : Aspect-Oriented Programming with the RealProxy Class