Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ActivitySpanId.cs
Go to the documentation of this file.
5
6namespace System.Diagnostics;
7
8public readonly struct ActivitySpanId : IEquatable<ActivitySpanId>
9{
10 private readonly string _hexString;
11
12 internal ActivitySpanId(string hexString)
13 {
14 _hexString = hexString;
15 }
16
17 public unsafe static ActivitySpanId CreateRandom()
18 {
19 Unsafe.SkipInit(out ulong num);
22 }
23
25 {
26 if (idData.Length != 8)
27 {
28 throw new ArgumentOutOfRangeException("idData");
29 }
31 }
32
34 {
35 return new ActivitySpanId(idData);
36 }
37
39 {
40 if (idData.Length != 16 || !ActivityTraceId.IsLowerCaseHexAndNotAllZeros(idData))
41 {
42 throw new ArgumentOutOfRangeException("idData");
43 }
44 return new ActivitySpanId(idData.ToString());
45 }
46
47 public string ToHexString()
48 {
49 return _hexString ?? "0000000000000000";
50 }
51
52 public override string ToString()
53 {
54 return ToHexString();
55 }
56
57 public static bool operator ==(ActivitySpanId spanId1, ActivitySpanId spandId2)
58 {
59 return spanId1._hexString == spandId2._hexString;
60 }
61
62 public static bool operator !=(ActivitySpanId spanId1, ActivitySpanId spandId2)
63 {
64 return spanId1._hexString != spandId2._hexString;
65 }
66
67 public bool Equals(ActivitySpanId spanId)
68 {
69 return _hexString == spanId._hexString;
70 }
71
72 public override bool Equals([NotNullWhen(true)] object? obj)
73 {
74 if (obj is ActivitySpanId activitySpanId)
75 {
76 return _hexString == activitySpanId._hexString;
77 }
78 return false;
79 }
80
81 public override int GetHashCode()
82 {
83 return ToHexString().GetHashCode();
84 }
85
86 private unsafe ActivitySpanId(ReadOnlySpan<byte> idData)
87 {
88 if (idData.Length != 16)
89 {
90 throw new ArgumentOutOfRangeException("idData");
91 }
92 if (!Utf8Parser.TryParse(idData, out ulong value, out int _, 'x'))
93 {
94 _hexString = CreateRandom()._hexString;
95 return;
96 }
98 {
100 }
102 }
103
108}
static readonly bool IsLittleEndian
static sbyte ReverseEndianness(sbyte value)
static bool TryParse(ReadOnlySpan< byte > source, out bool value, out int bytesConsumed, char standardFormat='\0')
static unsafe string ToString(ReadOnlySpan< byte > bytes, Casing casing=Casing.Upper)
static bool operator==(ActivitySpanId spanId1, ActivitySpanId spandId2)
unsafe ActivitySpanId(ReadOnlySpan< byte > idData)
static bool operator!=(ActivitySpanId spanId1, ActivitySpanId spandId2)
bool Equals(ActivitySpanId spanId)
static ActivitySpanId CreateFromBytes(ReadOnlySpan< byte > idData)
static unsafe ActivitySpanId CreateRandom()
static ActivitySpanId CreateFromUtf8String(ReadOnlySpan< byte > idData)
void CopyTo(Span< byte > destination)
static ActivitySpanId CreateFromString(ReadOnlySpan< char > idData)
override bool Equals([NotNullWhen(true)] object? obj)
static bool IsLowerCaseHexAndNotAllZeros(ReadOnlySpan< char > idData)
static void SetSpanFromHexChars(ReadOnlySpan< char > charData, Span< byte > outBytes)
static void SetToRandomBytes(Span< byte > outBytes)
override string ToString()