Example #1
0
 /// <summary>
 /// Returns the TraceId as a 16 character hexadecimal string.
 /// </summary>
 /// <returns></returns>
 public string ToHexString()
 {
     if (_asHexString == null)
     {
         fixed(ulong *idPtr = &_id1)
         _asHexString = ActivityTraceId.SpanToHexString(new ReadOnlySpan <byte>(idPtr, sizeof(ulong)));
     }
     return(_asHexString);
 }
Example #2
0
        /// <summary>
        /// Returns the TraceId as a 16 character hexadecimal string.
        /// </summary>
        /// <returns></returns>
        public string ToHexString()
        {
            if (_asHexString == null)
            {
                fixed(ulong *idPtr = &_id1)
                {
                    // Cast away the read-only-ness of _asHexString, and assign the converted value to it.
                    // We are OK with this because conceptually the class is still read-only.
                    ref string strRef = ref Unsafe.AsRef(in _asHexString);

                    Interlocked.CompareExchange(ref strRef, ActivityTraceId.SpanToHexString(new ReadOnlySpan <byte>(idPtr, sizeof(ulong))), null);
                }
            }