대체 Ninject 간단한 Injector
-
11-12-2019 - |
문제
나는 사용 Ninject 에 대한 내 응용 프로그램이 있습니다.Ninject 은 정말 간단하고 쉽게 배울 수 있지만,그것의 매우 느리고 사용하려고 시도하는 또 다른 IoC 을 비교하는 경우로 빠르게 함께 Ninject.
많은 IoC 컨테이너에 대한 MVC3 및 인젝터 간단한 외모는 정말 좋은이지만,저는 한 많은 문제가 replacting Ninject 과 간단한 Injector.
특히 AutoMapper
.I 로 변환하려고 하는 이선으로 인젝터 코드입니다.
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>()
당신은 당신의 도움을 받을 수 있습니까?나는 설명서를 읽고 봤는데,지금까지 솔루션.
해결책
이 Ninject 등록에 대하여 다음과 같은 간단한 등록 인젝터:
container.Register<ITypeMapFactory, TypeMapFactory>();
container.RegisterCollection<IObjectMapper>(MapperRegistry.AllMappers());
container.RegisterSingleton<IConfiguration, ConfigurationStore>();
container.RegisterSingleton<IConfigurationProvider, ConfigurationStore>();
container.Register<IMappingEngine, MappingEngine>();
제휴하지 않습니다 StackOverflow