IronPython 属性不可调用

IronPython attribute is not callable

我对以下 IronPython 属性 (RouteAttribute) 有疑问:

import clr
import System
from System.Web.Http import HttpGetAttribute, ApiController, RouteAttribute


class DemoController(ApiController):

    @RouteAttribute("~/api/test")
    def test(self):
        return "Hallo Welt!"

class DemoControllerClr:

    def getType(self):
        return clr.GetClrType(DemoController)

如果我创建 DemoController-Class 的实例,我总是会收到错误消息:RouteAttribute is not callable。我不会自己创建 DemoController 的实例,asp.net 网络 api 2 会尝试这样做。

也许有人对 IronPython 中的属性有一些经验。

编辑

我的目标是混合使用 C# 和 IronPython API-Controller。我这样注册控制器(C# 的有效):

controller = new Dictionary<string, System.Web.Http.Controllers.HttpControllerDescriptor>();

controller.Add("General", new System.Web.Http.Controllers.HttpControllerDescriptor(config, "General", typeof(Controller.GeneralController)));

foreach (DBScript script in dbContext.LoadData<DBScript>(optWherePart: "ScriptContentType = 1"))
{ 
    System.Diagnostics.Debugger.Launch();

    var sc = ScriptManager.Singleton.CreateScript(script.ScriptName, ScriptLanguage.IronPython);

    var clrInst = sc.GetClassInstance(script.ScriptName + "Clr");

    controller.Add(script.ScriptName.Replace("Controller", ""), new System.Web.Http.Controllers.HttpControllerDescriptor(config,
        script.ScriptName.Replace("Controller", ""), clrInst.getType()));
}

EDIT2

我正在使用最新版本的 IronPython (2.7.5)。

谢谢!

这没有用,因为依赖注入机制不能与 ironpython 一起工作,因为 dlr。所以就不要工作了。