Cola.SnowFlake
3.0.0
dotnet add package Cola.SnowFlake --version 3.0.0
NuGet\Install-Package Cola.SnowFlake -Version 3.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="Cola.SnowFlake" Version="3.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Cola.SnowFlake" Version="3.0.0" />
<PackageReference Include="Cola.SnowFlake" />
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 Cola.SnowFlake --version 3.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Cola.SnowFlake, 3.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.
#addin nuget:?package=Cola.SnowFlake&version=3.0.0
#tool nuget:?package=Cola.SnowFlake&version=3.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
ColaSnowFlake 雪花ID
1. 配置文件配置
"ColaSnowFlake": {
"DatacenterId": 1,
"WorkerId": 1
}
2. 注入方式
//通过配置文件注入
builder.Services.AddSingletonSnowFlake(config);
// 直接注入
builder.Services.AddSingletonSnowFlake(option =>
{
option.DatacenterId = 1;
option.WorkerId = 1;
});
3. 使用方式
//生成雪花Id
var long = IColaSnowFlake.CreateSnowFlakeId();
//解析雪花ID 解析后的字符串格式: datetime_datacenterId_workerId_sequence
string str = IColaSnowFlake.AnalyzeId(long snowFlakeId);
Product | Versions 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 was computed. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Cola.Console (>= 3.0.0)
- Cola.Models.Core (>= 3.0.0)
- Cola.Utils (>= 3.0.0)
- Microsoft.Extensions.Configuration (>= 8.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 8.0.0)
- Microsoft.Extensions.DependencyInjection (>= 8.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 8.0.0)