Kotz.DependencyInjection
2.2.2-nightly-058
This is a prerelease version of Kotz.DependencyInjection.
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Kotz.DependencyInjection --version 2.2.2-nightly-058
NuGet\Install-Package Kotz.DependencyInjection -Version 2.2.2-nightly-058
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="Kotz.DependencyInjection" Version="2.2.2-nightly-058" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Kotz.DependencyInjection --version 2.2.2-nightly-058
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Kotz.DependencyInjection, 2.2.2-nightly-058"
#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 Kotz.DependencyInjection as a Cake Addin #addin nuget:?package=Kotz.DependencyInjection&version=2.2.2-nightly-058&prerelease // Install Kotz.DependencyInjection as a Cake Tool #tool nuget:?package=Kotz.DependencyInjection&version=2.2.2-nightly-058&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Kotz.DependencyInjection
- Dependencies:
Microsoft.Extensions.DependencyInjection.Abstractions
Defines the following extension methods:
- IServiceCollection Extensions
- RegisterServices: Registers all classes and structs from an assembly that have a
ServiceAttributeBase
attribute applied to them.
- RegisterServices: Registers all classes and structs from an assembly that have a
- IServiceProvider and IServiceScopeFactory Extensions
- GetParameterizedService: Gets a service that requires arguments that are not registered in the IoC container.
- GetScopedService: Gets a service that needs to be resolved from a scope.
Defines the following types:
- ServiceAttributeBase: It's the base class for dependency injection registrations.
- ServiceAttribute: Marks a class or struct for registration via the
IServiceCollection.RegisterServices
extension method. - ServiceAttribute<T>: Marks a class or struct for registration under the type
T
via theIServiceCollection.RegisterServices
extension method.
Using the registration attributes
- Registering the type directly
// Registration.
[Service(ServiceLifetime.Singleton)]
public sealed class MyService { ... }
// Resolution.
serviceProvider.GetRequiredService<MyService>();
- Registering the type through another type.
// Registration.
[Service<ISomething>(ServiceLifetime.Scoped)]
public sealed class MyService : ISomething { ... }
// Resolution.
serviceProvider.GetRequiredService<ISomething>();
- Registering multiple types under the same type.
[Service<ISomething>(ServiceLifetime.Transient, true)]
public sealed class MyService1 : ISomething { ... }
[Service<ISomething>(ServiceLifetime.Transient, true)]
public sealed class MyService2 : ISomething { ... }
[Service<ISomething>(ServiceLifetime.Transient, true)]
public sealed class MyService3 : ISomething { ... }
- Registering the services in the
IServiceCollection
.
// To register services from the current assembly.
serviceCollection.RegisterServices();
// OR
// To register services from a specific assembly.
serviceCollection.RegisterServices(someAssembly);
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. 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 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net7.0
-
net8.0
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Kotz.DependencyInjection:
Package | Downloads |
---|---|
Kotz.Utilities
Provides utility types and methods for common tasks. This is a metapackage that includes all Kotz utility packages. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.3.3-nightly-075 | 76 | 5/25/2024 |
2.3.2 | 92 | 5/25/2024 |
2.3.1 | 90 | 5/25/2024 |
2.3.0 | 92 | 5/24/2024 |
2.3.0-nightly-070 | 79 | 5/24/2024 |
2.3.0-nightly-069 | 77 | 5/24/2024 |
2.3.0-nightly-068 | 76 | 5/24/2024 |
2.3.0-nightly-067 | 80 | 5/24/2024 |
2.3.0-nightly-066 | 82 | 5/24/2024 |
2.3.0-nightly-065 | 79 | 5/23/2024 |
2.3.0-nightly-064 | 77 | 5/23/2024 |
2.3.0-nightly-062 | 58 | 5/16/2024 |
2.2.2-nightly-059 | 92 | 4/16/2024 |
2.2.2-nightly-058 | 76 | 4/10/2024 |
2.2.2-nightly-057 | 79 | 4/9/2024 |
2.2.2-nightly-056 | 78 | 4/4/2024 |
2.2.1 | 152 | 3/21/2024 |
2.2.1-nightly-054 | 56 | 3/21/2024 |
2.2.1-nightly-053 | 79 | 3/20/2024 |
2.2.1-nightly-051 | 79 | 3/16/2024 |
2.2.0 | 179 | 12/17/2023 |
2.2.0-nightly-049 | 89 | 12/23/2023 |
2.2.0-nightly-048 | 114 | 12/17/2023 |
2.2.0-nightly-042 | 120 | 9/23/2023 |
2.2.0-nightly-041 | 102 | 9/23/2023 |
2.2.0-nightly-039 | 103 | 9/23/2023 |