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 | 539 | 7/31/2020 |
1.0.0.28 | 435 | 7/31/2020 |
1.0.0.27 | 594 | 3/2/2019 |
1.0.0.19 | 857 | 7/15/2018 |
1.0.0.18 | 927 | 7/11/2018 |
1.0.0.17 | 881 | 7/11/2018 |
1.0.0.16 | 774 | 7/2/2018 |
1.0.0.15 | 906 | 6/23/2018 |
1.0.0.14 | 913 | 6/21/2018 |
1.0.0.13 | 894 | 6/18/2018 |
1.0.0.12 | 889 | 6/17/2018 |
1.0.0.11 | 880 | 6/16/2018 |
1.0.0.10 | 922 | 6/16/2018 |
1.0.0.9 | 878 | 6/16/2018 |
1.0.0.8 | 877 | 6/16/2018 |
1.0.0.7 | 946 | 6/1/2018 |
1.0.0.6 | 916 | 6/1/2018 |
1.0.0.5 | 921 | 5/24/2018 |
1.0.0.4 | 931 | 5/13/2018 |
1.0.0.3 | 897 | 5/12/2018 |
1.0.0.2 | 927 | 5/12/2018 |
1.0.0.1 | 976 | 4/29/2018 |
1.0.0 | 949 | 4/17/2018 |
Features:
- Added option to enable/disable automatic type resolution
- Added option to enable/disable automatic type instantiation