src/Orleans.Core.Abstractions/IDs/GrainIdKeyExtensions.cs
/// <summary>
/// Creates an <see cref="IdSpan"/> representing a <see cref="Guid"/> key and key extension string.
/// </summary>
/// <param name="key">
/// The key.
/// </param>
/// <param name="keyExtension">
/// The key extension.
/// </param>
/// <returns>
/// An <see cref="IdSpan"/> representing the provided key and key extension.
/// </returns>
Creates an  representing a  key and key extension string.
Creates an representing a key and key extension string .
public static IdSpan CreateGuidKey(Guid key, string keyExtension)
        {
            if (string.IsNullOrWhiteSpace(keyExtension))
            {
                return CreateGuidKey(key);
            }
            var extLen = Encoding.UTF8.GetByteCount(keyExtension);
            var buf = new byte[32 + 1 + extLen];
            Utf8Formatter.TryFormat(key, buf, out var len, 'N');
            Debug.Assert(len == 32, "Unable to format the provided value as a UTF8 string");
            buf[32] = (byte)'+';
            Encoding.UTF8.GetBytes(keyExtension, 0, keyExtension.Length, buf, 33);
            return new IdSpan(buf);
        }
public static IdSpan CreateGuidKey ( Guid key , string keyExtension ) { if ( string . IsNullOrWhiteSpace ( keyExtension ) ) { return CreateGuidKey ( key ) ; } var extLen = Encoding . UTF8 . GetByteCount ( keyExtension ) ; var buf = new byte [ 32 + 1 + extLen ] ; Utf8Formatter . TryFormat ( key , buf , out var len , ' ' ) ; Debug . Assert ( len == 32 , " " ) ; buf [ 32 ] = ( byte ) ' ' ; Encoding . UTF8 . GetBytes ( keyExtension , 0 , keyExtension . Length , buf , 33 ) ; return new IdSpan ( buf ) ; }
Creates an  representing a  key and key extension string.
Creates an representing a key and key extension string .
An  representing the provided key and key extension.
An representing the provided key and key extension .
key
Guid
None
keyExtension
string
The key extension.
The key extension .