Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
DiagnosticCounter.cs
Go to the documentation of this file.
3using System.Text;
4
6
7[UnsupportedOSPlatform("browser")]
8public abstract class DiagnosticCounter : IDisposable
9{
10 private string _displayName = "";
11
12 private string _displayUnits = "";
13
15
17
18 public string DisplayName
19 {
20 get
21 {
22 return _displayName;
23 }
24 set
25 {
26 if (value == null)
27 {
28 throw new ArgumentNullException("DisplayName");
29 }
31 }
32 }
33
34 public string DisplayUnits
35 {
36 get
37 {
38 return _displayUnits;
39 }
40 set
41 {
42 if (value == null)
43 {
44 throw new ArgumentNullException("DisplayUnits");
45 }
47 }
48 }
49
50 public string Name { get; }
51
52 public EventSource EventSource { get; }
53
54 internal DiagnosticCounter(string name, EventSource eventSource)
55 {
56 if (name == null)
57 {
58 throw new ArgumentNullException("Name");
59 }
60 if (eventSource == null)
61 {
62 throw new ArgumentNullException("EventSource");
63 }
64 Name = name;
65 EventSource = eventSource;
66 }
67
68 private protected void Publish()
69 {
71 _group.Add(this);
72 }
73
74 public void Dispose()
75 {
76 if (_group != null)
77 {
78 _group.Remove(this);
79 _group = null;
80 }
81 }
82
83 public void AddMetadata(string key, string? value)
84 {
85 lock (this)
86 {
87 if (_metadata == null)
88 {
90 }
92 }
93 }
94
95 internal abstract void WritePayload(float intervalSec, int pollingIntervalMillisec);
96
97 internal void ReportOutOfBandMessage(string message)
98 {
100 }
101
102 internal string GetMetadataString()
103 {
104 if (_metadata == null)
105 {
106 return "";
107 }
109 bool flag = enumerator.MoveNext();
111 if (!enumerator.MoveNext())
112 {
113 return current.Key + ":" + current.Value;
114 }
115 StringBuilder stringBuilder = new StringBuilder().Append(current.Key).Append(':').Append(current.Value);
116 do
117 {
118 current = enumerator.Current;
119 stringBuilder.Append(',').Append(current.Key).Append(':')
120 .Append(current.Value);
121 }
122 while (enumerator.MoveNext());
123 return stringBuilder.ToString();
124 }
125}
void Add(TKey key, TValue value)
static CounterGroup GetCounterGroup(EventSource eventSource)
void Remove(DiagnosticCounter eventCounter)
void Add(DiagnosticCounter eventCounter)
void WritePayload(float intervalSec, int pollingIntervalMillisec)
DiagnosticCounter(string name, EventSource eventSource)
void AddMetadata(string key, string? value)
StringBuilder Append(char value, int repeatCount)