dependency_injection_build 1.0.0.5

There is a newer version of this package available.
See the version list below for details.
dotnet add package dependency_injection_build --version 1.0.0.5
NuGet\Install-Package dependency_injection_build -Version 1.0.0.5
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="dependency_injection_build" Version="1.0.0.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add dependency_injection_build --version 1.0.0.5
#r "nuget: dependency_injection_build, 1.0.0.5"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install dependency_injection_build as a Cake Addin
#addin nuget:?package=dependency_injection_build&version=1.0.0.5

// Install dependency_injection_build as a Cake Tool
#tool nuget:?package=dependency_injection_build&version=1.0.0.5

Welcome to the build wiki!

.NET Core 2.1 Dependency Injection framework

VSTS CircleCI Travis pipeline status Amazon AWS

Community

Welcome to #build #slack

CodeFactor NuGet version NuGet downloads Discord

Channels

#slack

Repository

build

Docs

wiki

v1.0.0.5

  • Automatic parameters cleanup
  • Registered ValueType instantiation
  • RuntimeAliasedTypes,RuntimeNonAliasedTypes,RuntimeTypes & RuntimeTypeAliases properties
  • Reset() function

Examples

Automatic parameters cleanup

Usage:

var instance1 = (SqlDataRepository)container.CreateInstance("Build.Tests.TestSet3.SqlDataRepository(System.Int32)", 123);
var instance2 = (SqlDataRepository)container.CreateInstance("Build.Tests.TestSet3.SqlDataRepository(System.Int32)");
Assert.Equal(0, instance2.PersinId);
Registered ValueType instantiation

Usage:

var instance = (int)container.CreateInstance("System.Int32()");
Assert.True(instance == 0);
RuntimeAliasedTypes,RuntimeNonAliasedTypes,RuntimeTypes & RuntimeTypeAliases properties

Usage:

var instances = container.RuntimeAliasedTypes.Select(p => container.CreateInstance(p));
Assert.True(instances.All(p => p != null));
var instances = container.RuntimeNonAliasedTypes.Select(p => container.CreateInstance(p));
Assert.True(instances.All(p => p != null));
var instances = container.RuntimeTypes.Select(p => container.CreateInstance(p));
Assert.True(instances.All(p => p != null));
var instances = container.RuntimeTypeAliases.Select(p => container.CreateInstance(p));
Assert.True(instances.All(p => p != null));
Reset() function

Usage:

container.RegisterType<SqlDataRepository>();
container.RegisterType<ServiceDataRepository>();
bool exception = false;
try
{
    container.Reset();
}
catch (Exception)
{
    exception = true;
}
Assert.False(exception);

Description

  • Interface first-class support (instantiation, strong typing, external assembly)
  • Circular references detection in type registration
  • Automatic type resolution for all supported types
  • Pure type instantiation (weak coupling)
  • Declarative metadata attribute driven initialization
  • Lazy type resolution and initialization (supports pure dependency injection decoupling anti-pattern)
  • Singleton initialization support
  • Automated and manual type registration
  • Types aliases (user-friendly type identification)
  • External assembly types support

v1.0.0.0

  • Elimination of overlapped attribute specificators (removes violation of the SOLID principles)
  • Circular references detection phase moved to type registration rather instantiation
  • Automatic type resolution for all supported types if used in type instantiation
  • Pure type instantiation as descriptive string with particular constructor and passing corresponding parameters

Features

  • Declarative metadata attribute driven initialization
  • Lazy type resolution and initialization (supports pure dependency decoupling anti-pattern)
  • Circular references detection
  • Singleton initialization
  • Automated and manual type registration
  • Type aliases
  • External assembly types

Goal

The goal of development of this framework is to build automation of complex types initialization. Build can use declarative approach to define dependencies between types and their requirements. Constructor injection uses type resolution to resolve devendencies

Examples

Create instance with parameters

Usage:

var container = new Container();
container.RegisterType<SqlDataRepository>();
container.RegisterType<ServiceDataRepository>();
var sql = new SqlDataRepository();
var srv1 = (ServiceDataRepository)container.CreateInstance(
    "UnitTests.TestSet14.ServiceDataRepository(UnitTests.TestSet14.SqlDataRepository)", sql);

Load simple types (not attributes specified)

Usage:

IContainer container = new Container();
container.RegisterType<SqlDataRepository>();
container.RegisterType<ServiceDataRepository>();
var srv1 = container.CreateInstance<ServiceDataRepository>();

Load of external assembly type

Load type using interface

Classes

Definition:

public interface IPersonRepository
{
    Person GetPerson(int personId);
}

public class Person
{
    readonly IPersonRepository _personRepository;

    public Person(IPersonRepository personRepository)
    {
        _personRepository = personRepository;
    }
}

public class SqlDataRepository : IPersonRepository
{
    public SqlDataRepository()
    {
    }

    public Person GetPerson(int personId)
    {
        // get the data from SQL DB and return Person instance.
        return new Person(this);
    }
}

public class ServiceDataRepository : IPersonRepository
{
    public ServiceDataRepository(SqlDataRepository repository)
    {
        Repository = repository;
    }
    public IPersonRepository Repository { get; }
    public Person GetPerson(int personId)
    {
        // get the data from Web service and return Person instance.
        return new Person(this);
    }
}

Continious Integration

CircleCI TravisCI

Dependency injection in ASP.NET Core

Inversion of Control Containers and the Dependency Injection pattern

Support via PayPal

Please, feel free to donate me 5$ to expand project development (wiki, samples, etc.)

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.1 is compatible.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETCoreApp 2.1

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0.31 498 7/31/2020
1.0.0.28 402 7/31/2020
1.0.0.27 559 3/2/2019
1.0.0.19 828 7/15/2018
1.0.0.18 897 7/11/2018
1.0.0.17 853 7/11/2018
1.0.0.16 745 7/2/2018
1.0.0.15 873 6/23/2018
1.0.0.14 883 6/21/2018
1.0.0.13 866 6/18/2018
1.0.0.12 860 6/17/2018
1.0.0.11 853 6/16/2018
1.0.0.10 894 6/16/2018
1.0.0.9 850 6/16/2018
1.0.0.8 848 6/16/2018
1.0.0.7 916 6/1/2018
1.0.0.6 891 6/1/2018
1.0.0.5 885 5/24/2018
1.0.0.4 906 5/13/2018
1.0.0.3 870 5/12/2018
1.0.0.2 902 5/12/2018
1.0.0.1 946 4/29/2018
1.0.0 920 4/17/2018

Features:
- Automatic parameters cleanup
- Registered ValueType instantiation
- RuntimeAliasedTypes,RuntimeNonAliasedTypes,RuntimeTypes & RuntimeTypeAliases properties
- Reset() function