SuguruSasaki / pure-di

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PureDI (C#)

This library help you Dependency Injection pattern using Pure DI.
PureDI was proposed by Mark Seemann.
Jeon Suyeol made a great library with Swift.

This library is a port of Swift's Pure to C #.

About Pure DI

PureDI does not use the DI container. Usually Pure DI will use constructor injection.

// Constructor injection
public SampleClass(Dependency dependency, Palyad payload) {

}

Of course this is also good, but in C # we use the Inject method.

public void Inject(IDepedencyType dependency, IPayloadType payload) {

}

Dependency injection is done by Composition Root. This idea is very powerful.

public class CompositionRoot {
    private CompositionRoot(Dependency dependency, Payload payload) {
        this.dependency = dependency;
        this.payload = payload;
    }

    public static CompositionRoot Resolve() {
        var dependency = new Dependency();
        var payload = new Payload();
        return new CompositionRoot(dependency: dependency, payload: payload);
    }
}

Usage

About


Languages

Language:C# 100.0%