ByteDev.Ioc.MsExtDi 1.0.0

Collection of extensions for Microsoft Extensions DI in a .NET Standard 2.0 assembly.

Install-Package ByteDev.Ioc.MsExtDi -Version 1.0.0
dotnet add package ByteDev.Ioc.MsExtDi --version 1.0.0
<PackageReference Include="ByteDev.Ioc.MsExtDi" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ByteDev.Ioc.MsExtDi --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

ByteDev.Ioc.MsExtDi

Collection of extensions for Microsoft Extensions DI.

Installation

ByteDev.Ioc.MsExtDi has been written as a .NET Standard 2.0 library, so you can consume it from a .NET Core or .NET Framework 4.6.1 (or greater) application.

ByteDev.Ioc.MsExtDi is hosted as a package on nuget.org. To install from the Package Manager Console in Visual Studio run:

Install-Package ByteDev.Ioc.MsExtDi

Further details can be found on the nuget page.

Code

The repo can be cloned from git bash:

git clone https://github.com/ByteDev/ByteDev.Ioc.MsExtDi

Usage

Create installer class

This is to register your classes with and configure any settings. The class should implement IServiceInstaller.

Example:

public class FoobarInstaller : IServiceInstaller
{
    public void Install(IServiceCollection services, IConfiguration configuration)
    {
        services.AddSingleton<IFoobar, Foobar>();

        services.ConfigureSettings<FoobarSettings>(configuration);
    }
}

Install the installers

// Use ConfigurationBuilder or AppConfigurationBuilder to create a IConfiguration

var serviceCollection = new ServiceCollection();

serviceCollection.InstallFromAssemblyContaining<FoobarInstaller>(configuration);

Inject class dependencies / resolve dependencies

To resolve a registered dependency using service locator (anti)pattern:

IServiceProvider provider = serviceCollection.BuildServiceProvider();

var foobar = provider.GetService<IFoobar>();

Further examples can be seen in the Unit and Integration test projects.

ByteDev.Ioc.MsExtDi

Collection of extensions for Microsoft Extensions DI.

Installation

ByteDev.Ioc.MsExtDi has been written as a .NET Standard 2.0 library, so you can consume it from a .NET Core or .NET Framework 4.6.1 (or greater) application.

ByteDev.Ioc.MsExtDi is hosted as a package on nuget.org. To install from the Package Manager Console in Visual Studio run:

Install-Package ByteDev.Ioc.MsExtDi

Further details can be found on the nuget page.

Code

The repo can be cloned from git bash:

git clone https://github.com/ByteDev/ByteDev.Ioc.MsExtDi

Usage

Create installer class

This is to register your classes with and configure any settings. The class should implement IServiceInstaller.

Example:

public class FoobarInstaller : IServiceInstaller
{
    public void Install(IServiceCollection services, IConfiguration configuration)
    {
        services.AddSingleton<IFoobar, Foobar>();

        services.ConfigureSettings<FoobarSettings>(configuration);
    }
}

Install the installers

// Use ConfigurationBuilder or AppConfigurationBuilder to create a IConfiguration

var serviceCollection = new ServiceCollection();

serviceCollection.InstallFromAssemblyContaining<FoobarInstaller>(configuration);

Inject class dependencies / resolve dependencies

To resolve a registered dependency using service locator (anti)pattern:

IServiceProvider provider = serviceCollection.BuildServiceProvider();

var foobar = provider.GetService<IFoobar>();

Further examples can be seen in the Unit and Integration test projects.

Version History

Version Downloads Last updated
1.0.0 168 8/20/2018