2011-10-17 2 views
3

Unity 또는 StructureMap에 익숙하지 않습니다. 다음 StructureMap 등록 샘플을 Unity 등록 구문으로 어떻게 변환합니까?Unity에 AutoMapper 등록

public class ConfigurationRegistry : Registry 
    { 
     public ConfigurationRegistry() 
     { 
      ForRequestedType<ConfigurationStore>() 
       .CacheBy(InstanceScope.Singleton) 
       .TheDefault.Is.OfConcreteType<ConfigurationStore>() 
       .CtorDependency<IEnumerable<IObjectMapper>>().Is(expr => expr.ConstructedBy(MapperRegistry.AllMappers)); 

      ForRequestedType<IConfigurationProvider>() 
       .TheDefault.Is.ConstructedBy(ctx => ctx.GetInstance<ConfigurationStore>()); 

      ForRequestedType<IConfiguration>() 
       .TheDefault.Is.ConstructedBy(ctx => ctx.GetInstance<ConfigurationStore>()); 

      ForRequestedType<IMappingEngine>().TheDefaultIsConcreteType<MappingEngine>(); 

      ForRequestedType<ITypeMapFactory>().TheDefaultIsConcreteType<TypeMapFactory>(); 
     } 
    } 
+0

해결책으로 답을 써야합니다. – onof

답변

0

나는 그것을 얻었습니다. 내가 뭔가를 놓친다면 알려줘.

Container 
.RegisterType<ConfigurationStore, ConfigurationStore> 
           (
           new ContainerControlledLifetimeManager() 
           , new InjectionConstructor(typeof(ITypeMapFactory) 
           , MapperRegistry.AllMappers()) 
          ) 
.RegisterType<IConfigurationProvider, ConfigurationStore>() 
.RegisterType<IConfiguration, ConfigurationStore>() 
.RegisterType<IMappingEngine, MappingEngine>() 
.RegisterType<ITypeMapFactory, TypeMapFactory>();