src/DotCommon/Utility/ObjectId.cs
/// <summary>
/// Unpacks a byte array into the components of an ObjectId.
/// </summary>
/// <param name="bytes">A byte array.</param>
/// <param name="timestamp">The timestamp.</param>
/// <param name="machine">The machine hash.</param>
/// <param name="pid">The PID.</param>
/// <param name="increment">The increment.</param>
Unpacks a byte array into the components of an ObjectId.
Unpacks a byte array into the components of an ObjectId .
public static void Unpack(byte[] bytes, out int timestamp, out int machine, out short pid, out int increment)
        {
            if (bytes == null)
            {
                throw new ArgumentNullException(nameof(bytes));
            }
            if (bytes.Length != 12)
            {
                throw new ArgumentOutOfRangeException(nameof(bytes), "Byte array must be 12 bytes long.");
            }
            timestamp = (bytes[0] << 24) + (bytes[1] << 16) + (bytes[2] << 8) + bytes[3];
            machine = (bytes[4] << 16) + (bytes[5] << 8) + bytes[6];
            pid = (short)((bytes[7] << 8) + bytes[8]);
            increment = (bytes[9] << 16) + (bytes[10] << 8) + bytes[11];
        }
public static void Unpack ( byte [ ] bytes , out int timestamp , out int machine , out short pid , out int increment ) { if ( bytes == null ) { throw new ArgumentNullException ( nameof ( bytes ) ) ; } if ( bytes . Length != 12 ) { throw new ArgumentOutOfRangeException ( nameof ( bytes ) , " " ) ; } timestamp = ( bytes [ 0 ] << 24 ) + ( bytes [ 1 ] << 16 ) + ( bytes [ 2 ] << 8 ) + bytes [ 3 ] ; machine = ( bytes [ 4 ] << 16 ) + ( bytes [ 5 ] << 8 ) + bytes [ 6 ] ; pid = ( short ) ( ( bytes [ 7 ] << 8 ) + bytes [ 8 ] ) ; increment = ( bytes [ 9 ] << 16 ) + ( bytes [ 10 ] << 8 ) + bytes [ 11 ] ; }
Unpacks a byte array into the components of an ObjectId.
Unpacks a byte array into the components of an ObjectId .
bytes
byte[]
A byte array.
A byte array .
int
out
short
out
timestamp
None
machine
The machine hash.
The machine hash .
pid
None
increment
None