1

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.

0

1 Answer 1

1

Sure, here is an example:

services.AddScoped<IContextFactory, ContextFactory>(provider => 
    new ContextFactory(server, databaseName, username, password));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.