Note that there are some explanatory texts on larger screens.

plurals
  1. POAutofac - DDD layered application - reference generics of iRepository - howto?
    primarykey
    data
    text
    <p>So i'm using Autofac in my application that looks as follow (from top -down approach).</p> <p>The project is in MVC 4 and i added the AutoFac.MVC4 beta.</p> <ul> <li>Web App Client (the web application - presentation layer): namespace = AppBase.Web</li> <li>Web App Core (eg. various actionresults, ...): namespace = AppBase.Web.Core</li> <li>Services (eg. AuthenticationService, MemberService, TaskService): namespace = AppBase.Service</li> <li>Data (includes Repositories, ...): namespace = AppBase.Data</li> <li>Domain (POCO objects for Code Fist): namespace = AppBase.Domain</li> </ul> <p>I included Autofac in my Web App Client with the following initialization code (for now):</p> <pre><code>public void RegisterContainersUsingAutofac() { var builder = new ContainerBuilder(); builder.RegisterModelBinders(Assembly.GetExecutingAssembly()); builder.RegisterModelBinderProvider(); builder.RegisterControllers(typeof(MvcApplication).Assembly); IContainer container = builder.Build(); DependencyResolver.SetResolver(new AutofacDependencyResolver(container)); } </code></pre> <p>Web App Client references the core, domain and services layer. The Service layer references the Data layer (for Repositories).</p> <p>I have an interface in my data layer called iRepository, all my Repositories implement these </p> <p>I'm wondering, what code should i add to my "RegisterContainersUsingAutofac" method, to automaticly (in a generic way) add all Repositories and Services, so i shouldn't add them myselve everytime. Keep in mind, the datalayer isn't referenced (i can, but i don't think it should).</p> <p>PS. I used Unity in the past, but i like the generic methods that AutoFac has (in one project, i have over +/-180 lines with adding repositories and services, so this is something i don't want anymore).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload