何时更新 Structuremap.MVC5 nuget 包以支持 Structuremap 4.x?

When will the Structuremap.MVC5 nuget package be updated to support Structuremap 4.x?

如果您安装了 StructureMap.MVC5 nuget 包,并更新了 structuremap nuget 包,ControllerConvention class 将要求您实施 ScanTypes 方法(来自更新的 IRegistrationConvention 接口)。这是方法签名:

public void ScanTypes(TypeSet types, Registry registry)

所以我的问题是,

  1. 是否会有 StructureMap.MVC5 nuget 包的更新版本?
  2. 我应该如何实现该方法?

谢谢。

根据 Charles Duffy 的回复,我进行了搜索并找到了答案: https://github.com/webadvanced/Structuremap.MVC5/issues/15

public void ScanTypes(TypeSet types, Registry registry)
{
    types.AllTypes().ForEach(type =>
    {
        if (type.CanBeCastTo<Controller>() && !type.IsAbstract)
        {
            registry.For(type).LifecycleIs(new UniquePerRequestLifecycle());
        }
    });
}

海报(和我)是"not sure if this is the best way to go"。

似乎不​​会更新 Structuremap.MVC5 包以直接支持 Structuremap 4.x。

然而,一个相对较小的改变就会让它工作。

@mnwsmit 在这里给出了很好的实现解释 -