StowayNet.Extensions.DependencyInjection
5.0.0
See the version list below for details.
dotnet add package StowayNet.Extensions.DependencyInjection --version 5.0.0
NuGet\Install-Package StowayNet.Extensions.DependencyInjection -Version 5.0.0
<PackageReference Include="StowayNet.Extensions.DependencyInjection" Version="5.0.0" />
paket add StowayNet.Extensions.DependencyInjection --version 5.0.0
#r "nuget: StowayNet.Extensions.DependencyInjection, 5.0.0"
// Install StowayNet.Extensions.DependencyInjection as a Cake Addin #addin nuget:?package=StowayNet.Extensions.DependencyInjection&version=5.0.0 // Install StowayNet.Extensions.DependencyInjection as a Cake Tool #tool nuget:?package=StowayNet.Extensions.DependencyInjection&version=5.0.0
StowayNet.Extensions.DependencyInjection 中文
StowayNet.Extensions.DependencyInjection is Dependency Injection extension methods for .net core, it can easily implement dependency injection.
Get Started
NuGet
You can run the following command to install the StowayNet.Extensions.DependencyInjection
in your project.
PM> Install-Package StowayNet.Extensions.DependencyInjection
Configuration
First,You need to config StowayNet.Extensions.DependencyInjection
in your Startup.cs
:
......
using StowayNet;
......
public void ConfigureServices(IServiceCollection services)
{
......
services.AddStowayNet();
......
}
Sample
Sample 1:implement IStowayDependency
empty interface
IStowayDependency
is an empty interface, all class and its subclasses that implement IStowayDependency
interface will injected into Transient
lifecyle。
public class BookService : IStowayDependency
{
......
}
If you want to inject Scoped
and Singleton
lifecycle, you need to add the attribute StowayDependencyAttribute
to class.
Sample 2:StowayDependencyAttribute
Adding the attribute StowayDependencyAttribute
to class, specifying the StowayDependencyType
parameter, the lifecycles of Transient
、Scoped
、 Singleton
can be injected, the attribute can be inherited by derived classes.
[StowayDependency(StowayDependencyType.Scoped)]
public class BookService {
}
......
[StowayDependency(StowayDependencyType.Singleton)]
public class AuthorService {
}
Sample 3:implement Register
method of IStowayServiceRegister
interface.
By implementing Register
method of IStowayServiceRegister
interface, you can implement a custom injection service.
internal class PressServiceRegister : IStowayServiceRegister
{
public void Register(IServiceCollection services, List<Type> types, IConfiguration configuration)
{
var serviceType = typeof(IBookService);
var stTypes = types.Where(t => !t.IsAbstract && !t.IsInterface).ToList();
services.RegisterTypes(stTypes, ServiceLifetime.Scoped, true, true);
}
}
At the same time, the configuration of other third-party frameworks can also be managed in this way.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. 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. |
-
net5.0
- Microsoft.Extensions.Configuration.Abstractions (>= 5.0.0)
- Microsoft.Extensions.DependencyInjection (>= 5.0.0)
- Microsoft.Extensions.DependencyModel (>= 5.0.0)
NuGet packages (6)
Showing the top 5 NuGet packages that depend on StowayNet.Extensions.DependencyInjection:
Package | Downloads |
---|---|
TronNet
TronNet is a SDK that includes libraries for working with TRON. TronNet makes it easy to build TRON applications with .net. |
|
TronNet_xiaobei
修复查询代币 转帐 精度:18 溢出问题 2022 修复usdt 精度计算错误 .net6 |
|
StowayNet.Extensions.Quartz
Package Description |
|
StowayNet.Extensions.Snowflake
Package Description |
|
AiYi.TronNet
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
Release notes are at https://github.com/stoway/StowayNet.Extensions.DependencyInjection/releases