Created
October 29, 2014 13:22
-
-
Save cyberzed/118c2e53832ccb3d891b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AutoMapperInstaller : IWindsorInstaller | |
{ | |
public void Install(IWindsorContainer container, IConfigurationStore store) | |
{ | |
container.Register( | |
Classes.FromThisAssembly() | |
.BasedOn<Profile>() | |
.WithService | |
.Base() | |
); | |
container.Register( | |
Component.For<IEnumerable<IObjectMapper>>() | |
.UsingFactoryMethod(() => MapperRegistry.Mappers) | |
); | |
container.Register( | |
Component.For<ITypeMapFactory>() | |
.ImplementedBy<TypeMapFactory>() | |
); | |
container.Register( | |
Component.For<ConfigurationStore>() | |
.ImplementedBy<ConfigurationStore>() | |
.LifestyleSingleton() | |
); | |
container.Register( | |
Component.For<IConfigurationProvider>() | |
.UsingFactoryMethod(kernel => | |
{ | |
var configuration = kernel.Resolve<ConfigurationStore>(); | |
var profiles = container.ResolveAll<Profile>(); | |
foreach (var profile in profiles) | |
{ | |
configuration.AddProfile(profile); | |
} | |
return configuration; | |
}) | |
); | |
container.Register( | |
Component.For<IConfiguration>() | |
.UsingFactoryMethod(kernel => kernel.Resolve<ConfigurationStore>()) | |
); | |
container.Register( | |
Component.For<IMappingEngine>() | |
.ImplementedBy<MappingEngine>() | |
.LifestyleSingleton() | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment