Skip to content

Bootstrap implementations to Dependency Injection Container

License

Notifications You must be signed in to change notification settings

NicoZweifel/Bootstrapper

 
 

Repository files navigation

Bootstrapper.Extensions.Microsoft.DependencyInjection

Is .net standard library as a solution to bootstrap implementations and register them into Dependency Injection Container.

Installation

PM > Install-Package Bootstrapper.Extensions.Microsoft.DependencyInjection

How to Use?

In order to use the package you need to have implementation of IBootstrapper inside your project:

internal class TestBootstrapper : IBootstrapper
{
    /// <inheritdoc/>
    public IServiceCollection Initialize(IServiceCollection collection, IConfiguration configuration)
    {
        // ...
        // Register Transient, Scoped, or Singleton implementations.    
        // ...  

        return services;
    }
}

Integrated in Asp.Net Core

There are two options to bootstrap inside Program.cs:

  1. Automatic scanning for calling assembly:
using System.Reflection;
using Bootstrapper.Extensions.Microsoft.DependencyInjection;

//....

var builder = WebApplication.CreateBuilder(args);
//....
builder.Services.Bootstrap(builder.Configuration);
//....
  1. Using selective assemblies:
using System.Reflection;
using Bootstrapper.Extensions.Microsoft.DependencyInjection;

//....

var builder = WebApplication.CreateBuilder(args);
//....
builder.Services.Bootstrap(builder.Configuration, typeof(ClassA).Assemlby, typeof(ClassB).Assemlby);
//....

About

Bootstrap implementations to Dependency Injection Container

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%