2017-09-10 14:17:06 +02:00
2017-09-10 14:15:06 +02:00
2017-09-09 19:06:08 +02:00
2017-09-09 23:30:56 +02:00
2017-09-09 23:14:12 +02:00
2017-09-09 22:45:06 +02:00
2017-09-09 19:06:08 +02:00
2017-09-10 14:17:06 +02:00

Dependify

Build Status Version

Library that allows the developer to register his services by adding attributes to class or factory methods. Library works only with Microsoft's Microsoft.Extensions.DependencyInjection package.

Why the name? Because I wanted to contribute to the following list.

Installation

dotnet add package Dependify --version 1.0.0-* or search using NuGet Package Manager.

Requirements

  • .netstandard 2.0
  • Currently works only with IServiceCollection from Microsoft.Extensions.DependencyInjection

Usage

Let's have following interface and class

public interface ICar {

}

public class Audi : ICar {

}

Class Attributes

Single interface

If you want to add Audi as an implementation of ICar into IServiceCollection you just need to add RegisterTransient, RegisterScoped or RegisterSingleton attribute like

[RegisterTransient]
public class Audi : ICar {

}

and call

public void ConfigureServices(IServiceCollection services) {
    services.AutoRegister(); 
}

Multiple interfaces

If your class implements multiple interfaces, you can specify which one should be registered

[RegisterTransient(typeof(IFuelConsumer)]
public class Audi : ICar, IFuelConsumer {

}

Factory method attributes

If you want to add Audi as an implementation of ICar using static factory method, you can do following

[RegisterTransientFactory(typeof(ICar))]
public static Audi CreateAudi(IServiceProvider provider) {
    return new Audi();
}
Description
No description provided
Readme MIT 54 KiB
Languages
C# 100%