Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- IKernel kernel = new StandardKernel(
- new InlineModule(
- x => x.Bind<ICustomerRepository>().To<CustomerRepository>(),
- x => x.Bind<ICustomerService>().To<CustomerService>(),
- x => x.Bind<Form1>().ToSelf()
- ));
- ObjectFactory.Initialize(x =>
- {
- x.UseDefaultStructureMapConfigFile = false;
- x.ForRequestedType<ICustomerRepository>()
- .TheDefaultIsConcreteType<CustomerRepository>()
- .CacheBy(InstanceScope.Singleton);
- x.ForRequestedType<ICustomerService>()
- .TheDefaultIsConcreteType<CustomerService>()
- .CacheBy(InstanceScope.Singleton);
- x.ForConcreteType<Form1>();
- });
- container.RegisterType<ICustomerRepository, CustomerRepository>()
- .RegisterType<ICustomerService, CustomerService>();
- IWindsorContainer container = new WindsorContainer();
- container.AddComponentWithLifestyle<ICustomerRepository, CustomerRepository>("CustomerRepository", LifestyleType.Singleton);
- container.AddComponentWithLifestyle<ICustomerService, CustomerService>("CustomerService",LifestyleType.Singleton);
- container.AddComponent<Form1>("Form1");
- var builder = new ContainerBuilder();
- builder.Register<CustomerRepository>()
- .As<ICustomerRepository>()
- .ContainerScoped();
- builder.Register<CustomerService>()
- .As<ICustomerService>()
- .ContainerScoped();
- builder.Register<Form1>();
Add Comment
Please, Sign In to add comment