Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ GetInt32Config()

static int System.AppContextConfigHelper.GetInt32Config ( string configName,
int defaultValue,
bool allowNegative = true )
inlinestaticpackage

Definition at line 26 of file AppContextConfigHelper.cs.

27 {
28 try
29 {
30 object data = AppContext.GetData(configName);
31 int num = defaultValue;
32 if (!(data is uint num2))
33 {
34 if (data is string text)
35 {
36 num = ((!text.StartsWith('0')) ? int.Parse(text, NumberStyles.AllowLeadingSign, NumberFormatInfo.InvariantInfo) : ((text.Length < 2 || text[1] != 'x') ? Convert.ToInt32(text, 8) : Convert.ToInt32(text, 16)));
37 }
38 else if (data is IConvertible convertible)
39 {
40 num = convertible.ToInt32(NumberFormatInfo.InvariantInfo);
41 }
42 }
43 else
44 {
45 num = (int)num2;
46 }
47 return (!allowNegative && num < 0) ? defaultValue : num;
48 }
49 catch (FormatException)
50 {
51 return defaultValue;
52 }
53 catch (OverflowException)
54 {
55 return defaultValue;
56 }
57 }

References System.AppContext.GetData(), System.Globalization.NumberFormatInfo.InvariantInfo, System.text, and System.Convert.ToInt32().

Referenced by System.Threading.PortableThreadPool.BlockingConfig.BlockingConfig(), and System.Threading.PortableThreadPool.HillClimbing.HillClimbing().