Skip to content

AgentPrismId

Namespace AgentPrism · Assembly AgentPrism.Abstractions.dll

UUID version 7 generator for AgentPrism identifiers (RFC 9562).

public static class AgentPrismId

objectAgentPrismId

object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

A UUIDv7 is time ordered: the first 48 bits are a Unix millisecond stamp. This keeps B-tree indexes from fragmenting and makes ORDER BY id return time order. It also avoids the central sequence bottleneck of bigserial.

We use our own implementation instead of Guid.CreateVersion7 from.NET 9. The reason: the package also targets net8.0, and storage keys must be produced the same way on every target.

Reads the time stamp back out of a UUIDv7.

public static DateTimeOffset GetTimestamp(Guid id)

id Guid

The UUIDv7 value.

DateTimeOffset

The time stamp embedded in the identifier.

ArgumentException

id is not a version 7 value.

Creates a new UUIDv7 stamped with the current time.

public static Guid NewId()

Guid

A time-ordered identifier.

Creates a UUIDv7 stamped with the given time.

public static Guid NewId(DateTimeOffset timestamp)

timestamp DateTimeOffset

The time stamp to embed in the identifier.

Guid

A time-ordered identifier.