Reputation: 19033
With Unity one can do something like this:
.RegisterType<IControllerFactory, MyControllerFactory>(
new InjectionConstructor("connectionstring goes here"));
Is it possible to do the same in ASP.NET Core?
UPD: I have controllers in a separate assembly where I would like to keep my presentation model that's why I'm substituting the controller factory. It needs to create different stuff in order to create controllers and this requires connection string.
Upvotes: 1
Views: 1245
Reputation: 1665
Sure, here is an example:
services.AddScoped<IContextFactory, ContextFactory>(provider =>
new ContextFactory(server, databaseName, username, password));
Upvotes: 1