Table of Contents

Class UuidFactory

Namespace
Shift.Common
Assembly
Shift.Common.dll
public class UuidFactory : IGuidGenerator
Inheritance
UuidFactory
Implements
Inherited Members
Extension Methods

Constructors

UuidFactory()

public UuidFactory()

Properties

NamespaceId

public static Guid NamespaceId { get; set; }

Property Value

Guid

Methods

Create()

Generates a Version 7 UUID value. This is the default version.

public static Guid Create()

Returns

Guid

CreateV3(Guid, string)

Generates a Version 3 UUID value.

public static Guid CreateV3(Guid space, string name)

Parameters

space Guid
name string

Returns

Guid

Remarks

Version-3 UUID values are generated based on a unique "namespace" and a unique "name". Namespace and name are concatenated and hashed. There is no temporal or random component, so the same input always produces the same output. In other words, this allows the caller to generate a unique deterministic hash for an arbitrary string value. The UUID specification establishes these 4 pre-defined namespaces: DNS (fully qualified domain names) = 6ba7b810-9dad-11d1-80b4-00c04fd430c8 URL (URLs) = 6ba7b811-9dad-11d1-80b4-00c04fd430c8 OID (object identifiers) = 6ba7b812-9dad-11d1-80b4-00c04fd430c8 XDN (X.500 distinguished names) = 6ba7b814-9dad-11d1-80b4-00c04fd430c8

CreateV4()

public static Guid CreateV4()

Returns

Guid

CreateV5(Guid, string)

Generates a Version 5 UUID value.

public static Guid CreateV5(Guid space, string name)

Parameters

space Guid
name string

Returns

Guid

Remarks

Version-5 UUID values are generated based on a unique "namespace" and a unique "name". Namespace and name are concatenated and hashed. There is no temporal or random component, so the same input always produces the same output. In other words, this allows the caller to generate a unique deterministic hash for an arbitrary string value. The UUID specification establishes these 4 pre-defined namespaces: DNS (fully qualified domain names) = 6ba7b810-9dad-11d1-80b4-00c04fd430c8 URL (URLs) = 6ba7b811-9dad-11d1-80b4-00c04fd430c8 OID (object identifiers) = 6ba7b812-9dad-11d1-80b4-00c04fd430c8 XDN (X.500 distinguished names) = 6ba7b814-9dad-11d1-80b4-00c04fd430c8

CreateV5(string)

public static Guid CreateV5(string name)

Parameters

name string

Returns

Guid

CreateV5ForDns(string)

public static Guid CreateV5ForDns(string email)

Parameters

email string

Returns

Guid

Remarks

The UUID DNS namespace is specifically designed for domain-name-based identifiers like email addresses, which typically follow the user@domain.com pattern. This ensures consistency and standardization when generating UUIDs for email addresses.

CreateV5ForUrl(string)

public static Guid CreateV5ForUrl(string resource)

Parameters

resource string

Returns

Guid

CreateV7()

Generates a Version 7 (timestamp and random) UUID value.

public static Guid CreateV7()

Returns

Guid

Remarks

The Guid.NewGuid() method generates a Version 4 UUID, which is suitable for scenarios where randomness is sufficient and there are no strict requirements for sequential or time-based ordering. Version 7 UUIDs (UUIDv7) are designed for keys in high-load databases and distributed systems. For more information about UUIDv7 values, refer to https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_7_(timestamp_and_random)

GetVersion(Guid)

public static int GetVersion(Guid guid)

Parameters

guid Guid

Returns

int

NewGuid()

public Guid NewGuid()

Returns

Guid

NewGuid(Type)

public Guid NewGuid(Type t)

Parameters

t Type

Returns

Guid