Dot.Versioning 1.0.0

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 and Polyglot Notebooks. 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                

Dot.Versioning

QQ:375089259

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)
{
    services.AddVersioning();
})

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

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

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

_serviceFactory.GetService<IService>("0.9").Display();
_serviceFactory.GetService<IService>("1.0").Display();
_serviceFactory.GetService<IService>("2.0").Display();
_serviceFactory.GetService<IService>("9999.9999.9999.9999").Display();
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
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 569 5/8/2020
1.0.0 455 5/6/2020