Skip to content

josiah-roberts/DeclareDI

Repository files navigation

DeclareDI

Declarative extension for Microsoft.Extensions.DependencyInjection, designed to allow functional-style, dependency-injected programming.

Usage

For higher-order functions:

public delegate DateTime NowPlusDays(int days);
public delegate string NowPlusDaysFormatted(int days);

public static class Functions {
    
    [Service]
    public static NowPlusDays NowPlusDays() => 
        (days) => DateTime.Now.AddDays(days);

    [Service]
    public static NowPlusDaysFormatted NowPlusDaysFormatted(NowPlusDays nowPlusDays) => 
        (days) => nowPlusDays(days).ToLongDateString();
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages