src/Orleans.Core.Abstractions/IDs/GrainIdKeyExtensions.cs
/// <summary>
/// Creates an <see cref="IdSpan"/> representing a <see cref="long"/> 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 CreateIntegerKey(long key, string keyExtension)
        {
            if (string.IsNullOrWhiteSpace(keyExtension))
            {
                return CreateIntegerKey(key);
            }
            Span<byte> tmp = stackalloc byte[sizeof(long) * 2];
            Utf8Formatter.TryFormat(key, tmp, out var len, 'X');
            Debug.Assert(len > 0, "Unable to format the provided value as a UTF8 string");
            var extLen = Encoding.UTF8.GetByteCount(keyExtension);
            var buf = new byte[len + 1 + extLen];
            tmp.Slice(0, len).CopyTo(buf);
            buf[len] = (byte)'+';
            Encoding.UTF8.GetBytes(keyExtension, 0, keyExtension.Length, buf, len + 1);
            return new IdSpan(buf);
        }
public static IdSpan CreateIntegerKey ( long key , string keyExtension ) { if ( string . IsNullOrWhiteSpace ( keyExtension ) ) { return CreateIntegerKey ( key ) ; } Span < byte > tmp = stackalloc byte [ sizeof ( long ) * 2 ] ; Utf8Formatter . TryFormat ( key , tmp , out var len , ' ' ) ; Debug . Assert ( len > 0 , " " ) ; var extLen = Encoding . UTF8 . GetByteCount ( keyExtension ) ; var buf = new byte [ len + 1 + extLen ] ; tmp . Slice ( 0 , len ) . CopyTo ( buf ) ; buf [ len ] = ( byte ) ' ' ; Encoding . UTF8 . GetBytes ( keyExtension , 0 , keyExtension . Length , buf , len + 1 ) ; 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
long
None
keyExtension
string
The key extension.
The key extension .