Skip to content

Instantly share code, notes, and snippets.

@cyberzed
Created October 29, 2014 13:22
Show Gist options
  • Save cyberzed/118c2e53832ccb3d891b to your computer and use it in GitHub Desktop.
Save cyberzed/118c2e53832ccb3d891b to your computer and use it in GitHub Desktop.
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