Anit.Sequence.Abstractions 10.0.0.2

dotnet add package Anit.Sequence.Abstractions --version 10.0.0.2
                    
NuGet\Install-Package Anit.Sequence.Abstractions -Version 10.0.0.2
                    
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="Anit.Sequence.Abstractions" Version="10.0.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Anit.Sequence.Abstractions" Version="10.0.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Anit.Sequence.Abstractions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Anit.Sequence.Abstractions --version 10.0.0.2
                    
#r "nuget: Anit.Sequence.Abstractions, 10.0.0.2"
                    
#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.
#:package Anit.Sequence.Abstractions@10.0.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Anit.Sequence.Abstractions&version=10.0.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Anit.Sequence.Abstractions&version=10.0.0.2
                    
Install as a Cake Tool

Anit.Sequence.Abstractions

Anit.Sequence.Abstractions 是一个序列号生成器的抽象接口库,提供了统一的序列号生成标准,支持各种序列号生成场景,如简单序列号、每日序列号和格式化序列号等。

功能特性

  • 提供统一的序列号生成接口定义
  • 支持多种序列号生成模式

安装

通过 NuGet 包管理器安装:

Install-Package Anit.Sequence.Abstractions

接口说明

IAnitSequenceGenerator 是核心接口,定义了序列号生成的标准方法:

public interface IAnitSequenceGenerator
{
    /// <summary>
    /// 获取下一个序列号
    /// </summary>
    /// <param name="sequenceCode">序列代码</param>
    /// <returns>序列号</returns>
    Task<int> NextNumberAsync(string sequenceCode);

    /// <summary>
    /// 获取下一个每日序列号
    /// </summary>
    /// <param name="sequenceCode">序列代码</param>
    /// <param name="dateFormat">日期格式</param>
    /// <returns>每日序列号</returns>
    Task<int> NextDailyNumberAsync(string sequenceCode, string dateFormat = "yyMMdd");

    /// <summary>
    /// 获取下一个格式化序列号
    /// </summary>
    /// <param name="sequenceCode">序列代码</param>
    /// <param name="dateFormat">日期格式</param>
    /// <param name="numberLength">数字长度</param>
    /// <returns>格式化序列号</returns>
    Task<string> NextSerialNumberAsync(string sequenceCode, string dateFormat = "yyMMdd", int numberLength = 5);

    /// <summary>
    /// 批量获取序列号
    /// </summary>
    /// <param name="count">获取数量</param>
    /// <param name="sequenceCode">序列代码</param>
    /// <returns>序列号数组</returns>
    Task<int[]> NextNumbersAsync(int count, string sequenceCode);

    /// <summary>
    /// 批量获取每日序列号
    /// </summary>
    /// <param name="count">获取数量</param>
    /// <param name="sequenceCode">序列代码</param>
    /// <param name="dateFormat">日期格式</param>
    /// <returns>每日序列号数组</returns>
    Task<int[]> NextDailyNumbersAsync(int count, string sequenceCode, string dateFormat = "yyMMdd");

    /// <summary>
    /// 批量获取格式化序列号
    /// </summary>
    /// <param name="count">获取数量</param>
    /// <param name="sequenceCode">序列代码</param>
    /// <param name="dateFormat">日期格式</param>
    /// <param name="numberLength">数字长度</param>
    /// <returns>格式化序列号数组</returns>
    Task<string[]> NextSerialNumbersAsync(int count, string sequenceCode, string dateFormat = "yyMMdd", int numberLength = 5);
}

已有的实现

  • Anit.Sequence.Redis.CSRedis:基于 Redis 的序列号生成器实现
  • Anit.Sequence.Redis.StackExchangeRedis:基于 StackExchange.Redis 的序列号生成器实现
  • 本项目提供了默认的基于字典的序列号生成器实现 DefaultAnitSequenceGenerator,用于处理单元测试,不可用于生产环境。

使用场景

这个抽象接口适用于以下场景:

  1. 需要生成订单号、流水号等唯一标识符的系统
  2. 需要按日期分组的序列号生成
  3. 需要格式化序列号(包含日期、固定前缀等)的业务场景
  4. 需要高性能批量生成序列号的场景
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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 Anit.Sequence.Abstractions:

Package Downloads
Anit.Sequence.Redis.Abstractions

基于 Redis 的序列生成器抽象库,提供了分布式环境下的序列生成功能接口和基类实现。

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
10.0.0.2 208 2/2/2026