Skip to content
This repository has been archived by the owner on Nov 2, 2018. It is now read-only.

Modules as wiring point #497

Closed
OlekRia opened this issue Mar 6, 2017 · 2 comments
Closed

Modules as wiring point #497

OlekRia opened this issue Mar 6, 2017 · 2 comments
Labels

Comments

@OlekRia
Copy link

OlekRia commented Mar 6, 2017

The main idea is to make another library being a wiring point.
So, in this case, it's really helpful from architecture point of view.
Our ASP.net core project can see two libraries:

  1. a lib with interfaces
  2. a library with implementations are bind.

In Ninject I can create Ninject module for example for this purpose..

I guess it's possible to do the same with this IOC.
Any advice?

@davidfowl
Copy link
Member

The pattern we've been using so far is basically extension methods that add to the IServiceCollection. We have no plans on adding any discovery or auto wire up of "modules". There needs to be code in the application that wires up the module.

Library

public static class MyModuleServiceCollectionExtensions
{
    public static IServiceCollection AddMyModule(this IServiceCollection services)
    {
        services.AddTransient<IFoo, Foo>();
        services.AddSingleton<IBar, Bar>();
        return services;
    }
}

And the application code does:

public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {
         services.AddMyModule();
    }
}

@Eilon Eilon closed this as completed Mar 27, 2017
@Eilon Eilon added the question label Mar 27, 2017
@Jetski5822
Copy link

@EmmaHansson you could look at the way we have done modular code in Orchard... https://github.com/OrchardCMS/Orchard2/tree/master/src/OrchardCore/Microsoft.AspNetCore.Modules - sounds what you are looking for.

A dummy MVC application here as an example https://github.com/OrchardCMS/Orchard2/tree/master/src/Orchard.Mvc.Web

Also the video by @sebastienros on channel9 gives a really good view on how to implement modular asp.net application using this stuff... https://channel9.msdn.com/Shows/On-NET/Sbastien-Ros-Modular-ASPNET-apps

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants