Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ActivityContext.cs
Go to the documentation of this file.
2
3namespace System.Diagnostics;
4
5public readonly struct ActivityContext : IEquatable<ActivityContext>
6{
7 public ActivityTraceId TraceId { get; }
8
9 public ActivitySpanId SpanId { get; }
10
12
13 public string? TraceState { get; }
14
15 public bool IsRemote { get; }
16
17 public ActivityContext(ActivityTraceId traceId, ActivitySpanId spanId, ActivityTraceFlags traceFlags, string? traceState = null, bool isRemote = false)
18 {
19 TraceId = traceId;
20 SpanId = spanId;
21 TraceFlags = traceFlags;
22 TraceState = traceState;
23 IsRemote = isRemote;
24 }
25
26 public static bool TryParse(string? traceParent, string? traceState, out ActivityContext context)
27 {
28 if (traceParent == null)
29 {
30 context = default(ActivityContext);
31 return false;
32 }
33 return Activity.TryConvertIdToContext(traceParent, traceState, out context);
34 }
35
36 public static ActivityContext Parse(string traceParent, string? traceState)
37 {
38 if (traceParent == null)
39 {
40 throw new ArgumentNullException("traceParent");
41 }
42 if (!Activity.TryConvertIdToContext(traceParent, traceState, out var context))
43 {
45 }
46 return context;
47 }
48
50 {
51 if (SpanId.Equals(value.SpanId) && TraceId.Equals(value.TraceId) && TraceFlags == value.TraceFlags && TraceState == value.TraceState)
52 {
53 return IsRemote == value.IsRemote;
54 }
55 return false;
56 }
57
58 public override bool Equals([NotNullWhen(true)] object? obj)
59 {
60 if (!(obj is ActivityContext value))
61 {
62 return false;
63 }
64 return Equals(value);
65 }
66
67 public static bool operator ==(ActivityContext left, ActivityContext right)
68 {
69 return left.Equals(right);
70 }
71
72 public static bool operator !=(ActivityContext left, ActivityContext right)
73 {
74 return !(left == right);
75 }
76
77 public override int GetHashCode()
78 {
79 return HashCode.Combine(TraceId, SpanId, TraceFlags, TraceState);
80 }
81}
static bool TryConvertIdToContext(string traceParent, string traceState, out ActivityContext context)
Definition Activity.cs:915
static string InvalidTraceParent
Definition SR.cs:38
Definition SR.cs:7
override bool Equals([NotNullWhen(true)] object? obj)
static ActivityContext Parse(string traceParent, string? traceState)
static bool TryParse(string? traceParent, string? traceState, out ActivityContext context)
static bool operator!=(ActivityContext left, ActivityContext right)
static bool operator==(ActivityContext left, ActivityContext right)
bool Equals(ActivityContext value)
ActivityContext(ActivityTraceId traceId, ActivitySpanId spanId, ActivityTraceFlags traceFlags, string? traceState=null, bool isRemote=false)
bool Equals(ActivitySpanId spanId)
bool Equals(ActivityTraceId traceId)