last ...
This commit is contained in:
@@ -1,15 +1,20 @@
|
||||
using System;
|
||||
using xDataService.Interfaces;
|
||||
|
||||
namespace xDataService.Helpers {
|
||||
namespace xDataService.Helpers
|
||||
{
|
||||
/// <summary>
|
||||
/// this service provide Sequential GUID mechanism for Entity Ids ...
|
||||
/// </summary>
|
||||
public class XSequentialGuid : IXSequentialGuid {
|
||||
public class XSequentialGuid : IXSequentialGuid
|
||||
{
|
||||
private static int[] sqlOrderMap = null;
|
||||
private static int[] SQLORDERMAP {
|
||||
get {
|
||||
if (sqlOrderMap == null) {
|
||||
private static int[] SQLORDERMAP
|
||||
{
|
||||
get
|
||||
{
|
||||
if (sqlOrderMap == null)
|
||||
{
|
||||
sqlOrderMap = new int[16] {
|
||||
3,
|
||||
2,
|
||||
@@ -37,24 +42,29 @@ namespace xDataService.Helpers {
|
||||
|
||||
private Guid currentGuid;
|
||||
|
||||
public XSequentialGuid () {
|
||||
currentGuid = Guid.NewGuid ();
|
||||
public XSequentialGuid()
|
||||
{
|
||||
currentGuid = Guid.NewGuid();
|
||||
}
|
||||
|
||||
public Guid GetCurrentGuid () {
|
||||
public Guid GetCurrentGuid()
|
||||
{
|
||||
return currentGuid;
|
||||
}
|
||||
|
||||
public Guid Next () {
|
||||
byte[] bytes = currentGuid.ToByteArray ();
|
||||
for (int mapIndex = 0; mapIndex < 16; mapIndex++) {
|
||||
public Guid Next()
|
||||
{
|
||||
byte[] bytes = currentGuid.ToByteArray();
|
||||
for (int mapIndex = 0; mapIndex < 16; mapIndex++)
|
||||
{
|
||||
int bytesIndex = SQLORDERMAP[mapIndex];
|
||||
bytes[bytesIndex]++;
|
||||
if (bytes[bytesIndex] != 0) {
|
||||
if (bytes[bytesIndex] != 0)
|
||||
{
|
||||
break; // No need to increment more significant bytes
|
||||
}
|
||||
}
|
||||
currentGuid = new Guid (bytes);
|
||||
currentGuid = new Guid(bytes);
|
||||
return currentGuid;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user