BorgNet.Core 1.0.0

dotnet add package BorgNet.Core --version 1.0.0
NuGet\Install-Package BorgNet.Core -Version 1.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="BorgNet.Core" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BorgNet.Core --version 1.0.0
#r "nuget: BorgNet.Core, 1.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 BorgNet.Core as a Cake Addin
#addin nuget:?package=BorgNet.Core&version=1.0.0

// Install BorgNet.Core as a Cake Tool
#tool nuget:?package=BorgNet.Core&version=1.0.0

依赖注入 除了使用官方原生依赖注入外,支持通过接口和正则模式注入

1、依赖接口

如果实现这些接口,则会自动将类注册到依赖注入:

ITransientDependency 注册为transient生命周期. ISingletonDependency 注册为singleton生命周期. IScopedDependency 注册为scoped生命周期

a、会将所有实现Demo1和Demo2类注入到容器中 public interface IDemoDependency :ITransientDependency { } public class Demo1 : IDemoDependency{} public class Demo2 : IDemoDependency{}

b、将当前DemoDependency 注入到容器中 public class DemoDependency : IDemoDependency, ITransientDependency {

} c、将当前DemoDependency 注入到容器中 public class DemoDependency : IDemoDependency {

} 2、 Dependency 特性

我们也可以给某个类打上特性标签的方法来确定要注入的类

配置依赖注入服务的另一种方法是使用DependencyAttribute.它具有以下属性:

Lifetime: 注册的生命周期:Singleton,Transient或Scoped. TryRegister: 设置true则只注册以前未注册的服务.使用IServiceCollection的TryAdd ... 扩展方法. ReplaceServices: 设置true则替换之前已经注册过的服务.使用IServiceCollection的Replace扩展方法. 示例: [Dependency(ServiceLifetime.Transient, ReplaceServices = true)] public class MyClass {

} 如果定义了Lifetime属性,则Dependency特性具有比其他依赖接口更高的优先级. 3、ExposeServices 特性

ExposeServicesAttribute用于控制相关类提供了什么服务.例: ExposeServicesAttribute

[ExposeServices(typeof(ITaxCalculator))] public class TaxCalculator: ICalculator, ITaxCalculator, ICanCalculate, ITransientDependency {

}

TaxCalculator类只公开ITaxCalculator接口.这意味着你只能注入ITaxCalculator,但不能注入TaxCalculator或ICalculator到你的应用程序中. 更新中...

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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 (1)

Showing the top 1 NuGet packages that depend on BorgNet.Core:

Package Downloads
BorgNet.Localization

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 189 1/29/2023