dependency_injection_build 1.0.0.6
See the version list below for details.
dotnet add package dependency_injection_build --version 1.0.0.6
NuGet\Install-Package dependency_injection_build -Version 1.0.0.6
<PackageReference Include="dependency_injection_build" Version="1.0.0.6" />
paket add dependency_injection_build --version 1.0.0.6
#r "nuget: dependency_injection_build, 1.0.0.6"
// Install dependency_injection_build as a Cake Addin #addin nuget:?package=dependency_injection_build&version=1.0.0.6 // Install dependency_injection_build as a Cake Tool #tool nuget:?package=dependency_injection_build&version=1.0.0.6
Welcome to the build wiki!
.NET Core 2.1 Dependency Injection framework
Maintainability
Community
Channels
Repository
Docs
v1.0.0.6
- Enable/disable automatic type resolution
- Enable/disable automatic type instantiation
Examples
Automatic type resolution disabled
Parameter is set to true if automatic type resolution for reference types option enabled (does not throws exceptions for reference types contains type dependencies to non-registered types). If automatic type resolution for reference types is enabled, type will defaults to null if not resolved and no exception will be thrown.
Usage:
// Automatic type resolution disabled
// Instantiation reqires SqlDataRepository to be resolved
var container = new Container(false, true);
container.RegisterType<ServiceDataRepository>();
container.RegisterType<WebServiceDataRepository>();
Assert.Throws<TypeInstantiationException>(() => container.CreateInstance("Build.Tests.TestSet15.WebServiceDataRepository(Build.Tests.TestSet15.SqlDataRepository)"));
/// Automatic type resolution enabled
var container = new Container(true, false);
container.RegisterType<WebServiceDataRepository>();
var sql = (WebServiceDataRepository)container.CreateInstance("Build.Tests.TestSet15.WebServiceDataRepository(Build.Tests.TestSet15.SqlDataRepository)");
Assert.Equal(2019, ((SqlDataRepository)sql.Repository).PersonId);
Definition:
public class ServiceDataRepository : IPersonRepository
{
public ServiceDataRepository([Injection(typeof(SqlDataRepository), 2018)]IPersonRepository 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);
}
}
public class WebServiceDataRepository : IPersonRepository
{
public WebServiceDataRepository([Injection(typeof(SqlDataRepository), 2019)]IPersonRepository 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);
}
}
Automatic type instantiation disabled
Parameter is set to true if automatic type instantiation for reference types option enabled (does not throws exceptions for reference types defaults to null). If automatic type instantiation for reference types is enabled, type will defaults to null if not resolved and no exception will be thrown.
Usage:
// Automatic type instantiation disabled
var container = new Container(true, false);
container.RegisterType<ServiceDataRepository2>();
Assert.Throws<TypeInstantiationException>(() => container.CreateInstance<ServiceDataRepository2>());
// Automatic type instantiation enabled
// ServiceDataRepository2 depends upon non existent Build.Tests.Fail_TestSet1.Other2
// and resolved to null
var container = new Container(true, true);
container.RegisterType<ServiceDataRepository2>();
var sql = container.CreateInstance<ServiceDataRepository2>();
Assert.Null(sql.Repository);
Definition:
public class ServiceDataRepository2 : IPersonRepository
{
public ServiceDataRepository2([Injection("Build.Tests.Fail_TestSet1.Other2")]IPersonRepository 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);
}
}
Product | Versions 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. |
-
.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 | 537 | 7/31/2020 |
1.0.0.28 | 433 | 7/31/2020 |
1.0.0.27 | 592 | 3/2/2019 |
1.0.0.19 | 855 | 7/15/2018 |
1.0.0.18 | 925 | 7/11/2018 |
1.0.0.17 | 879 | 7/11/2018 |
1.0.0.16 | 772 | 7/2/2018 |
1.0.0.15 | 904 | 6/23/2018 |
1.0.0.14 | 911 | 6/21/2018 |
1.0.0.13 | 892 | 6/18/2018 |
1.0.0.12 | 887 | 6/17/2018 |
1.0.0.11 | 878 | 6/16/2018 |
1.0.0.10 | 920 | 6/16/2018 |
1.0.0.9 | 876 | 6/16/2018 |
1.0.0.8 | 875 | 6/16/2018 |
1.0.0.7 | 944 | 6/1/2018 |
1.0.0.6 | 914 | 6/1/2018 |
1.0.0.5 | 919 | 5/24/2018 |
1.0.0.4 | 929 | 5/13/2018 |
1.0.0.3 | 895 | 5/12/2018 |
1.0.0.2 | 925 | 5/12/2018 |
1.0.0.1 | 974 | 4/29/2018 |
1.0.0 | 947 | 4/17/2018 |
Features:
- Added option to enable/disable automatic type resolution
- Added option to enable/disable automatic type instantiation