添加项目文件。

This commit is contained in:
2025-12-02 13:10:10 +08:00
parent 93a2382a16
commit 289aa4cbe7
400 changed files with 91177 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
using IdGen;
using Microsoft.Extensions.Configuration;
namespace Atomx.Data.Services
{
/// <summary>
///
/// </summary>
public interface IIdCreatorService
{
/// <summary>
///
/// </summary>
/// <returns></returns>
long NewId();
}
/// <summary>
///
/// </summary>
public class IdCreatorService : IIdCreatorService
{
private IdGenerator IdCreator { get; set; }
/// <summary>
///
/// </summary>
/// <param name="configuration"></param>
public IdCreatorService(IConfiguration configuration)
{
DateTime epoch = new DateTime(2020, 1, 1, 0, 0, 0, DateTimeKind.Utc);
var structure = new IdStructure(45, 2, 16);
var options = new IdGeneratorOptions(structure, new DefaultTimeSource(epoch));
var workId = int.Parse(configuration.GetSection("IdWorkId").Value ?? "0");
IdCreator = new IdGenerator(workId, options);
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public long NewId()
{
return IdCreator.CreateId();
}
}
}