Skip to content

Automatically add dependencies to your IServiceCollection by namespaces (with some wildcard support) or as arrays of Types.

License

Notifications You must be signed in to change notification settings

haneytron/Imperative.AutoDI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Install:

  • PM> Install-Package Imperative.AutoDI
  • nuget install Imperative.AutoDI

Automatically add dependencies to your IServiceCollection by namespaces (with some wildcard support) or as arrays of Types.

Example usage in Program.cs:

using Imperative.AutoDI;

...

var builder = WebApplication.CreateBuilder(args);

builder.Host.ConfigureServices((context, services) =>
{
    // Configure Auto DI
    services.AddAutoDependencyInjection(config =>
    {
        // Singletons - with wildcard that will map anything in a namespace starting with "My.Namespace.Two"
        // including namespaces like "My.Namespace.TwoTimes" and "My.Namespace.Two.Three"
        config.AddSingletons("My.Namespace.One", "My.Namespace.Two*");
        // Scopeds - basic namespace usage, will only map the things at that exact namespace
        config.AddScopeds("OtherNamespace");
        // Transients - with wildcard that will map anything in a namespace starting with "Another.Namespace."
        // such as "Another.Namespace.Two" and "Another.Namespace.Testing.Three"
        config.AddTransients("Another.Namespace.*");
    });
});

...

var app = builder.Build();

About

Automatically add dependencies to your IServiceCollection by namespaces (with some wildcard support) or as arrays of Types.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages