Skip to content

Extension package for MS DI, that adds injection via properties by one method and one attribute

License

Notifications You must be signed in to change notification settings

Davidos533/ms-di-property-injection-extension

Repository files navigation

MS DI Property Injection

Nuget

Usage

Mark property for injection

using Microsoft.Extensions.DependencyInjection;

public class FooService : IFooService
{
    [Inject]
    public IBooService BooService { get; set; }

    public void Foo()
    {
        // just start using injected property
        BooService...
    }
}

Add services scan method in ConfigureServices

using Microsoft.Extensions.DependencyInjection;

...

 host.ConfigureServices((services)=>
            {               
                services.AddTransient<IBooService, BooService>();
                services.AddTransient<IFooService, FooService>();

                // scan method
                services.AddPropertyInjectedServices();
            });

Install

Install-Package DJMJ.Extensions.DependencyInjection.Property

About

Extension package for MS DI, that adds injection via properties by one method and one attribute

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages