de2bd2f9
“wangming”
项目初始化
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
using NCC.Dependency;
using System;
namespace NCC.DistributedIDGenerator
{
/// <summary>
/// ID 生成器
/// </summary>
[SuppressSniffer]
public static class IDGen
{
/// <summary>
/// 生成唯一 ID
/// </summary>
/// <param name="idGeneratorOptions"></param>
/// <param name="serviceProvider"></param>
/// <returns></returns>
public static object NextID(object idGeneratorOptions, IServiceProvider serviceProvider = default)
{
return App.GetService<IDistributedIDGenerator>(serviceProvider ?? App.RootServices).Create(idGeneratorOptions);
}
/// <summary>
/// 生成连续 GUID
/// </summary>
/// <param name="serviceProvider"></param>
/// <returns></returns>
public static Guid NextID(IServiceProvider serviceProvider = default)
{
var sequentialGuid = App.GetService(typeof(SequentialGuidIDGenerator), serviceProvider ?? App.RootServices) as IDistributedIDGenerator;
return (Guid)sequentialGuid.Create();
}
}
}
|