[英]Using ActionFilterAttribute with Class Library Project (.NET)
I would like to use 'WEB API' action filter attributes over 'Class Library' class methods. 我想在“类库”类方法上使用“ WEB API”操作过滤器属性。 Is that possible? 那可能吗? or Any advice? 或任何建议?
Not without more trouble than its worth. 没有比它的价值更多的麻烦。 Action filters are a feature of Web Api, so unless you are talking about putting Web Api controllers into your own library or using filters from your library within Web Api controllers, you won't be able to take advantage of them directly. 动作筛选器是Web Api的功能,因此,除非您谈论将Web Api控制器放入自己的库中或在Web Api控制器中使用库中的筛选器,否则您将无法直接利用它们。
A potential solution could be to use a proxy pattern or decorator pattern to handle cross-cutting concerns for your library. 潜在的解决方案可能是使用代理模式或装饰器模式来处理库的跨领域问题 。 Have a look at Aspect-Oriented Programming : Aspect-Oriented Programming with the RealProxy Class for details. 看一看面向方面的编程:使用RealProxy类的面向方面的编程以获取详细信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.