src/Orleans.Core.Abstractions/Core/GrainExtensions.cs
/// <summary>
/// Returns the Guid representation of a grain primary key.
/// </summary>
/// <param name="grain">The grain to find the primary key for.</param>
/// <returns>A Guid representing the primary key for this grain.</returns>
Returns the Guid representation of a grain primary key.
Returns the Guid representation of a grain primary key .
public static Guid GetPrimaryKey(this IAddressable grain)
        {
            var grainId = GetGrainId(grain);
            if (grainId.TryGetGuidKey(out var guid))
                return guid;
            if (LegacyGrainId.TryConvertFromGrainId(grainId, out var legacyId))
                return legacyId.GetPrimaryKey();
            if (grainId.TryGetIntegerKey(out var integerKey))
            {
                var N1 = integerKey;
                return new Guid(0, 0, 0, (byte)N1, (byte)(N1 >> 8), (byte)(N1 >> 16), (byte)(N1 >> 24), (byte)(N1 >> 32), (byte)(N1 >> 40), (byte)(N1 >> 48), (byte)(N1 >> 56));
            }
            throw new InvalidOperationException($"Unable to extract GUID key from grain id {grainId}");
        }
public static Guid GetPrimaryKey ( this IAddressable grain ) { var grainId = GetGrainId ( grain ) ; if ( grainId . TryGetGuidKey ( out var guid ) ) return guid ; if ( LegacyGrainId . TryConvertFromGrainId ( grainId , out var legacyId ) ) return legacyId . GetPrimaryKey ( ) ; if ( grainId . TryGetIntegerKey ( out var integerKey ) ) { var N1 = integerKey ; return new Guid ( 0 , 0 , 0 , ( byte ) N1 , ( byte ) ( N1 >> 8 ) , ( byte ) ( N1 >> 16 ) , ( byte ) ( N1 >> 24 ) , ( byte ) ( N1 >> 32 ) , ( byte ) ( N1 >> 40 ) , ( byte ) ( N1 >> 48 ) , ( byte ) ( N1 >> 56 ) ) ; } throw new InvalidOperationException ( $" Unable to extract GUID key from grain id  { grainId } " ) ; }
Returns the Guid representation of a grain primary key.
Returns the Guid representation of a grain primary key .
A Guid representing the primary key for this grain.
A Guid representing the primary key for this grain .
IAddressable
this
grain
The grain to find the primary key for.
The grain to find the primary key for .