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

Capture and play voice with Asterisk ARI -

c++ - Can not find the "fiostream.h" file -

java - Why database contraints in HSQLDB are only checked during a commit when using transactions in Hibernate? -