【发布时间】:2017-10-06 13:40:35
【问题描述】:
我想在“类库”类方法上使用“WEB API”操作过滤器属性。那可能吗?或任何建议?
【问题讨论】:
标签: c# .net asp.net-web-api filter attributes
我想在“类库”类方法上使用“WEB API”操作过滤器属性。那可能吗?或任何建议?
【问题讨论】:
标签: c# .net asp.net-web-api filter attributes
并非没有比它的价值更多的麻烦。动作过滤器是 Web Api 的一项功能,因此除非您谈论将 Web Api 控制器放入您自己的库中或在 Web Api 控制器中使用您的库中的过滤器,否则您将无法直接利用它们。
一个潜在的解决方案可能是使用proxy pattern 或decorator pattern 为您的图书馆处理cross-cutting concerns。详情请查看Aspect-Oriented Programming : Aspect-Oriented Programming with the RealProxy Class。
【讨论】: