如何从webapi过滤器或其他属性导入导出的mef对象

时间:2019-02-20 10:32:17

标签: mef asp.net-web-api-filters

我想使用mef从webapi过滤器中调用外部方法

(它也已导出,我可以从代码的其他部分从构造者中导入它。)

有可能吗?

您能详细说明吗?

谢谢

例如代码:

public class SomeCustomFilter : ActionFilterAttribute
{
    [Import] ISomeServicer _someservice { get; set; }


    // static object foo
    public override void OnActionExecuting(HttpActionContext actionContext)
    {
         _someservice.getFoo();
    }

0 个答案:

没有答案