Browse Source

auto commit

tags/v1.0.0
zhouzj 3 years ago
parent
commit
c433f79504
1 changed files with 4 additions and 5 deletions
  1. +4
    -5
      C#.NET/source/Yitter.IdGenerator/DefaultIdGenerator.cs

+ 4
- 5
C#.NET/source/Yitter.IdGenerator/DefaultIdGenerator.cs View File

@@ -40,15 +40,14 @@ namespace Yitter.IdGenerator
throw new ApplicationException("BaseTime error."); throw new ApplicationException("BaseTime error.");
} }
if (options.SeqBitLength + options.WorkerIdBitLength > 22)
{
throw new ApplicationException("error:WorkerIdBitLength + SeqBitLength <= 22");
}
if (options.WorkerIdBitLength <= 0) if (options.WorkerIdBitLength <= 0)
{ {
throw new ApplicationException("WorkerIdBitLength error.(range:[1, 21])"); throw new ApplicationException("WorkerIdBitLength error.(range:[1, 21])");
} }
if (options.SeqBitLength + options.WorkerIdBitLength > 22)
{
throw new ApplicationException("error:WorkerIdBitLength + SeqBitLength <= 22");
}
var maxWorkerIdNumber = Math.Pow(2, options.WorkerIdBitLength) - 1; var maxWorkerIdNumber = Math.Pow(2, options.WorkerIdBitLength) - 1;
if (options.WorkerId < 0 || options.WorkerId > maxWorkerIdNumber) if (options.WorkerId < 0 || options.WorkerId > maxWorkerIdNumber)


Loading…
Cancel
Save