asp.net core mvc - Dependencies in MVC 6 application of multilayered solution -


i developing solution includes data layer, business layer , ui layer (mvc 6 application).

mvc application works interfaces of business layer. doesn't know services (implementation of business layer) , data layer. has reference project contains business layer interfaces.

i have issue connected dependencies. according opinion, must add dependencies (including repositories , services) startup.cs file, mvc 6 application mustn't have references repositories or services.

how can add dependencies without adding references?

the mvc6 application must reference service , repository implementations, either directly or indirectly. thing should not construct instances of these implementations controller components.

so in other words, okay in startup.cs:

public void configureservices(iservicecollection services) {   services.addinstance<iserviceorrepo, serviceorrepoimpl>(); } 

it not okay in controller:

private readonly iserviceorrepo _serviceorrepo;  public mycontroller() {   this._serviceorrepo = new serviceorrepoimpl(); } 

but either way, @ runtime, controller must able resolve actual serviceorrepoimpl implementation instance 1 of referenced assemblies (via ioc container of course). means assembly or project contains implementation must referenced mvc project either directly or indirectly.


Comments

Popular posts from this blog

c# - Can I intercept a SOAP response in .NET before a content type binding mismatch ProtocolException? -

python - Terminate a gnome-terminal opened with subprocess -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -