5
我用我的應用程序使用Ninject。 Ninject非常簡單易學,但速度很慢,我試圖用另一個IoC來比較它是否與Ninject一樣快。用簡單的噴油器替換Ninject
MVC3有很多IoC容器,Simple Injector看起來對我來說真的很好,但是我用Simple Injector替代Ninject有很多問題。
特別是與AutoMapper
。我嘗試將此行轉換爲Simple Injector代碼。
Bind<ITypeMapFactory>().To<TypeMapFactory>();
foreach (var mapper in MapperRegistry.AllMappers())
{
Bind<IObjectMapper>().ToConstant(mapper);
}
Bind<ConfigurationStore>().ToSelf().InSingletonScope()
.WithConstructorArgument("mappers",
ctx => ctx.Kernel.GetAll<IObjectMapper>());
Bind<IConfiguration>()
.ToMethod(ctx => ctx.Kernel.Get<ConfigurationStore>());
Bind<IConfigurationProvider>().ToMethod(ctx =>
ctx.Kernel.Get<ConfigurationStore>());
Bind<IMappingEngine>().To<MappingEngine>()
你能幫助我嗎?我已閱讀文檔並進行了搜索,但目前尚無解決方案。
我們幫不了你,除非你說出它是什麼,你需要幫助。什麼失敗? – Mithon 2012-07-25 21:27:36