【问题标题】:Using ActionFilterAttribute with Class Library Project (.NET)将 ActionFilterAttribute 与类库项目 (.NET) 一起使用
【发布时间】:2017-10-06 13:40:35
【问题描述】:

我想在“类库”类方法上使用“WEB API”操作过滤器属性。那可能吗?或任何建议?

【问题讨论】:

    标签: c# .net asp.net-web-api filter attributes


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-07
      • 1970-01-01
      • 1970-01-01
      • 2021-11-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多