简体   繁体   English

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

[英]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.

相关问题 如何在类库ActionFilterAttribute中访问Unity容器? - How can get access to Unity container in a class library ActionFilterAttribute? 在类库项目中使用类 - Using classes in Class library project 在.net类库中检测调用项目的类型 - Detect calling project type in a .net class library .Net中的项目间(类库)通信 - Inter project (class library) communication in .Net 在 dot net core 项目中使用 dot net Entity Framework 类库构建 - Using dot net Entity Framework class library build in dot net core project 重定向实现ActionFilterAttribute的类 - Redirecting in a class that implements the ActionFilterAttribute 引用 .net 核心类库到项目的问题 - Issue with reference .net core class library to project 在 .net 核心控制台应用程序中使用 .net class 库时项目构建失败 - Project build failed while using .net class library in .net core console application 如何在ASP.NET中将一个类库项目插入另一个类库项目的另一个类中? - How to impelement one class of class library project into another class of another class library project in asp.net? 如何在ASP Net Core项目中添加类库项目的引用 - How to add reference of class library project in asp net core project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM