Skip to content

Latest commit

 

History

History
32 lines (25 loc) · 1.2 KB

README.md

File metadata and controls

32 lines (25 loc) · 1.2 KB

NuGet Build Status GitHub license

Generic Assembly Scanner (aka Gas)

This simple library implements assembly scanning in a generic and reusable way.

Usage Examples

The generic nature of this library makes it suitable for multiple purposes, here are just a few examples.

.NET Core DI

using Gas;

public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {
        AssemblyScanner
            .Scan(Assembly.GetExecutingAssembly())
            .ForEachConcreteClassImplementing<IService>()
                .ForEachImplementedInterface()
                .Do((classType, interfaceType) => 
                    services.AddScoped(interfaceType, classType))
            .ForEachConcreteClassImplementing<ITextParser>()
                .Do(t => services.AddScoped(typeof(ITextParser), t));
    }
}