Skip to content

A fluent API for registering services with Microsoft.Extensions.DependencyInjection

License

Notifications You must be signed in to change notification settings

nwendel/FluentRegistration

Repository files navigation

FluentRegistration Build Coverage

A fluent API for registering services with Microsoft.Extensions.DependencyInjection

Example

public class Example
{

    public void ConfigureServices(IServiceCollection services)
    {
        services.Register(r => r
            .FromThisAssembly()
            .Where(c => c.InThisNamespace() && c.AssignableTo<IService>())
            .WithServices
                .AllInterfaces()
                .Self()
            .Lifetime.Singleton());
            
        services.Register(c => c
            .For<IService>()
            .ImplementedBy<Implementation>()
            .Lifetime.Singleton());
            
        services.Register(r => r
            .ImplementedBy<Implementation>()
            .WithServices.AllInterfaces()
            .Lifetime.Singleton());
            
        services.Install<ServiceInstaller>();
        
        services.Install(i => i.FromThisAssembly());
    }

}

public class ServiceInstaller : IServiceInstaller
{

    public void Install(IServiceCollection services)
    {
        // Register services here
    }

}

About

A fluent API for registering services with Microsoft.Extensions.DependencyInjection

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages