Dot.Versioning 1.0.0

.NET Standard 2.1
There is a newer version of this package available.
See the version list below for details.
dotnet add package Dot.Versioning --version 1.0.0
NuGet\Install-Package Dot.Versioning -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="Dot.Versioning" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Dot.Versioning --version 1.0.0
#r "nuget: Dot.Versioning, 1.0.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Dot.Versioning as a Cake Addin
#addin nuget:?package=Dot.Versioning&version=1.0.0

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



1. 安装:Install-Package Dot.Versioning

2. 继承 IVersioningService 接口,如:

public interface IService : IVersioningService
    void Display();

3. 为接口实现打上标签,如:

[Versioning(Version = "1.0")]
public class ServiceV1 : IService
    public void Display()
        Console.Writeline("IService V1.0");

[Versioning(Version = "2.0")]
public class ServiceV2 : IService
    public void Display()
        Console.Writeline("IService V2.0");

4. 在 Startup 中注册 Versioning

public void ConfigureServices(IServiceCollection services)

5. 在要使用多版本服务的地方注入 IVersioningServiceFactory

6. 使用 IVersioningServiceFactory 获得具体版本的服务。

获取策略:根据版本号向下兼容,例如: IService 已注入版本号为 1.0 的实现 ServiceV1; 版本号为 2.0 的实现 ServiceV2. 传入目标版本号大于等于 2.0 时将得到 ServiceV2. 传入目标版本号介于 1.0 与 2.0(不包含)时将得到 ServiceV1. 如果目标版本号小于所有已注册版本号(如 0.9)时将返回版本号最小的实现 ServiceV1.

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.1
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

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.1 395 5/8/2020
1.0.0 337 5/6/2020