last ...
This commit is contained in:
@@ -1,31 +1,43 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using xCommons.Extensions;
|
||||
using xDataService.Interfaces;
|
||||
using xModels.Base;
|
||||
|
||||
namespace xDataService.Providers {
|
||||
public class XStringKeyGenerator : IXKeyGenerator<XBaseEntity<string>, string> {
|
||||
namespace xDataService.Providers
|
||||
{
|
||||
public class XStringKeyGenerator : IXKeyGenerator<XBaseEntity<string>, string>
|
||||
{
|
||||
private readonly IXSequentialGuid sequentialGuid;
|
||||
|
||||
public XStringKeyGenerator (IXSequentialGuid sequentialGuid = null) {
|
||||
public XStringKeyGenerator(IXSequentialGuid sequentialGuid = null)
|
||||
{
|
||||
this.sequentialGuid = sequentialGuid;
|
||||
}
|
||||
|
||||
public async Task<string> GenerateKey (IXBaseRepository<XBaseEntity<string>, string> repository) {
|
||||
public async Task<string> GenerateKey(
|
||||
IXBaseRepository<XBaseEntity<string>, string> repository,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
await Task.CompletedTask;
|
||||
|
||||
//
|
||||
if (sequentialGuid.IsNull ()) {
|
||||
return Guid.NewGuid ().ToString ();
|
||||
} else {
|
||||
return sequentialGuid.Next ().ToString ();
|
||||
if (sequentialGuid.IsNull())
|
||||
{
|
||||
return Guid.NewGuid().ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return sequentialGuid.Next().ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsEmpty (string id) {
|
||||
return id.IsNullOrEmpty ();
|
||||
public bool IsEmpty(string id)
|
||||
{
|
||||
return id.IsNullOrEmpty();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user