using IdGen; using Microsoft.Extensions.Configuration; namespace Atomx.Data.Services { /// /// /// public interface IIdCreatorService { /// /// /// /// long NewId(); } /// /// /// public class IdCreatorService : IIdCreatorService { private IdGenerator IdCreator { get; set; } /// /// /// /// 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); } /// /// /// /// public long NewId() { return IdCreator.CreateId(); } } }