src/Orleans.Core.Abstractions/IDs/SiloAddress.cs
/// <summary>
/// Returns a UTF8-encoded representation of this instance as a byte array.
/// </summary>
/// <returns>A UTF8-encoded representation of this instance as a byte array.</returns>
Returns a UTF8-encoded representation of this instance as a byte array.
Returns a UTF8 - encoded representation of this instance as a byte array .
internal unsafe byte[] ToUtf8String()
        {
            if (utf8 is null)
            {
                var addr = Endpoint.Address.ToString();
                var size = Encoding.UTF8.GetByteCount(addr);
                Span<byte> buf = stackalloc byte[size + 1 + 11 + 1 + 11];
                fixed (char* src = addr)
                fixed (byte* dst = buf)
                {
                    size = Encoding.UTF8.GetBytes(src, addr.Length, dst, buf.Length);
                }
                buf[size++] = (byte)':';
                var success = Utf8Formatter.TryFormat(Endpoint.Port, buf.Slice(size), out var len);
                Debug.Assert(success);
                Debug.Assert(len > 0);
                Debug.Assert(len <= 11);
                size += len;
                buf[size++] = (byte)SEPARATOR;
                success = Utf8Formatter.TryFormat(Generation, buf.Slice(size), out len);
                Debug.Assert(success);
                Debug.Assert(len > 0);
                Debug.Assert(len <= 11);
                size += len;
                utf8 = buf.Slice(0, size).ToArray();
            }
            return utf8;
        }
internal unsafe byte [ ] ToUtf8String ( ) { if ( utf8 is null ) { var addr = Endpoint . Address . ToString ( ) ; var size = Encoding . UTF8 . GetByteCount ( addr ) ; Span < byte > buf = stackalloc byte [ size + 1 + 11 + 1 + 11 ] ; fixed ( char * src = addr ) fixed ( byte * dst = buf ) { size = Encoding . UTF8 . GetBytes ( src , addr . Length , dst , buf . Length ) ; } buf [ size ++ ] = ( byte ) ' ' ; var success = Utf8Formatter . TryFormat ( Endpoint . Port , buf . Slice ( size ) , out var len ) ; Debug . Assert ( success ) ; Debug . Assert ( len > 0 ) ; Debug . Assert ( len <= 11 ) ; size += len ; buf [ size ++ ] = ( byte ) SEPARATOR ; success = Utf8Formatter . TryFormat ( Generation , buf . Slice ( size ) , out len ) ; Debug . Assert ( success ) ; Debug . Assert ( len > 0 ) ; Debug . Assert ( len <= 11 ) ; size += len ; utf8 = buf . Slice ( 0 , size ) . ToArray ( ) ; } return utf8 ; }
Returns a UTF8-encoded representation of this instance as a byte array.
Returns a UTF8 - encoded representation of this instance as a byte array .
// Allocate sufficient room for: address + ':' + port + '@' + generation
A UTF8-encoded representation of this instance as a byte array.
A UTF8 - encoded representation of this instance as a byte array .