I have multiple implementations of the same interface who all have the same constructor parameter (strConn). Is it possible to register all implementations with 1 container.Register call?
Here is what I have:
container.Register(
Classes.FromAssemblyContaining<IUserMenuDao>()
.BasedOn<IDataAccess>().WithService.FromInterface()
);
These implementations all have the same constructor parameter; strConn. Registering one would be:
container.Register(Component.For<IUserMenuDao>()
.DependsOn(new {strConn = ConfigurationManager.ConnectionStrings["ABC123"].ConnectionString})
.ImplementedBy<UserMenuDaoSqlServerImpl>());
Is there a way to register by convention similar to code sample #1 but using a DependsOn for all implementations?
Yes Indeed