You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace JwKdsV.Core.Utils
{
public class IdWorkerUtils
{
static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
private static object _lock = new object();
private static IdWorkerUtils _instance = null;
private static IdWorker _IdWorker = null;
public static IdWorkerUtils Instance
{
get
{
if (_instance == null)
{
lock (_lock)
{
_instance = new IdWorkerUtils();
_IdWorker = new IdWorker(1, 1, 0);
}
}
return _instance;
}
}
public string NextId()
{
return _IdWorker.NextId().ToString();
}
public long NextId(long sequence)
{
IdWorker _IdWorker = new IdWorker(1 , 1 , sequence);
return _IdWorker.NextId() + sequence;
}
}
}