Skip to content

haneytron/Imperative.AutoDI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 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

1 star

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages