Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
TraceSwitch.cs
Go to the documentation of this file.
1#define TRACE
2namespace System.Diagnostics;
3
4[SwitchLevel(typeof(TraceLevel))]
5public class TraceSwitch : Switch
6{
8 {
9 get
10 {
11 return (TraceLevel)base.SwitchSetting;
12 }
13 set
14 {
15 if (value < TraceLevel.Off || value > TraceLevel.Verbose)
16 {
18 }
19 base.SwitchSetting = (int)value;
20 }
21 }
22
23 public bool TraceError => Level >= TraceLevel.Error;
24
25 public bool TraceWarning => Level >= TraceLevel.Warning;
26
27 public bool TraceInfo => Level >= TraceLevel.Info;
28
29 public bool TraceVerbose => Level == TraceLevel.Verbose;
30
31 public TraceSwitch(string displayName, string? description)
32 : base(displayName, description)
33 {
34 }
35
36 public TraceSwitch(string displayName, string? description, string defaultSwitchValue)
37 : base(displayName, description, defaultSwitchValue)
38 {
39 }
40
41 protected override void OnSwitchSettingChanged()
42 {
43 int switchSetting = base.SwitchSetting;
44 if (switchSetting < 0)
45 {
47 base.SwitchSetting = 0;
48 }
49 else if (switchSetting > 4)
50 {
52 base.SwitchSetting = 4;
53 }
54 }
55
56 protected override void OnValueChanged()
57 {
58 base.SwitchSetting = (int)Enum.Parse(typeof(TraceLevel), base.Value, ignoreCase: true);
59 }
60}
TraceSwitch(string displayName, string? description, string defaultSwitchValue)
override void OnSwitchSettingChanged()
TraceSwitch(string displayName, string? description)
static void WriteLine(string? message)
Definition Trace.cs:179
static object Parse(Type enumType, string value)
Definition Enum.cs:368
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string TraceSwitchLevelTooHigh
Definition SR.cs:32
static string TraceSwitchInvalidLevel
Definition SR.cs:30
static string TraceSwitchLevelTooLow
Definition SR.cs:28
Definition SR.cs:7