StowayNet.Extensions.DependencyInjection 5.0.0

There is a newer version of this package available.
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                
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="StowayNet.Extensions.DependencyInjection" Version="5.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add StowayNet.Extensions.DependencyInjection --version 5.0.0                
#r "nuget: StowayNet.Extensions.DependencyInjection, 5.0.0"                
#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 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 TransientScopedSingleton 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.

Version Downloads Last updated
5.0.1 35,403 2/20/2021
5.0.0 1,087 1/1/2021