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>
/// <param name="keyExt">The output parameter to return the extended key part of the grain primary key, if extended primary key was provided for that grain.</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, out string keyExt)
        {
            var grainId = GetGrainId(grain);
            if (grainId.TryGetGuidKey(out var guid, out keyExt))
            {
                return guid;
            }
            if (LegacyGrainId.TryConvertFromGrainId(grainId, out var legacyId))
            {
                return legacyId.GetPrimaryKey(out keyExt);
            }
            if (grainId.TryGetIntegerKey(out var integerKey, out keyExt))
            {
                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 , out string keyExt ) { var grainId = GetGrainId ( grain ) ; if ( grainId . TryGetGuidKey ( out var guid , out keyExt ) ) { return guid ; } if ( LegacyGrainId . TryConvertFromGrainId ( grainId , out var legacyId ) ) { return legacyId . GetPrimaryKey ( out keyExt ) ; } if ( grainId . TryGetIntegerKey ( out var integerKey , out keyExt ) ) { 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
string
out
grain
The grain to find the primary key for.
The grain to find the primary key for .
keyExt
The output parameter to return the extended key part of the grain primary key, if extended primary key was provided for that grain.
The output parameter to return the extended key part of the grain primary key if extended primary key was provided for that grain .