用简单的注射器替换Ninject

我已经将Ninject用于我的应用程序。 Ninject非常简单易学,但速度很慢,我尝试使用另一个IoC来比较它是否比Ninject更快。

MVC3和Simple Injector有很多IoC容器看起来对我很好,但是我在使用Simple Injector重新替换Ninject时遇到了很多问题。

特别是使用AutoMapper 。 我尝试将这些行转换为Simple Injector代码。

 Bind().To(); foreach (var mapper in MapperRegistry.AllMappers()) { Bind().ToConstant(mapper); } Bind().ToSelf().InSingletonScope() .WithConstructorArgument("mappers", ctx => ctx.Kernel.GetAll()); Bind() .ToMethod(ctx => ctx.Kernel.Get()); Bind().ToMethod(ctx => ctx.Kernel.Get()); Bind().To() 

你能帮帮我吗? 我已经阅读了文档和Google搜索,但到目前为止还没有解决方案。

此Ninject注册大致转换为以下Simple Injector注册:

 container.Register(); container.RegisterCollection(MapperRegistry.AllMappers()); container.RegisterSingleton(); container.RegisterSingleton(); container.Register();