Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
RuntimeInformation.cs
Go to the documentation of this file.
3
5
6public static class RuntimeInformation
7{
8 private static string s_frameworkDescription;
9
10 private static string s_runtimeIdentifier;
11
12 private static string s_osDescription;
13
14 private static volatile int s_osArch = -1;
15
16 private static volatile int s_processArch = -1;
17
18 public static string FrameworkDescription
19 {
20 get
21 {
22 if (s_frameworkDescription == null)
23 {
24 ReadOnlySpan<char> readOnlySpan = typeof(object).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion;
25 int num = readOnlySpan.IndexOf('+');
26 if (num != -1)
27 {
28 readOnlySpan = readOnlySpan.Slice(0, num);
29 }
30 s_frameworkDescription = ((!readOnlySpan.Trim().IsEmpty) ? $"{".NET"} {readOnlySpan}" : ".NET");
31 }
33 }
34 }
35
36 public static string RuntimeIdentifier
37 {
38 get
39 {
40 object obj = s_runtimeIdentifier;
41 if (obj == null)
42 {
43 obj = (AppContext.GetData("RUNTIME_IDENTIFIER") as string) ?? "unknown";
45 }
46 return (string)obj;
47 }
48 }
49
50 public static string OSDescription
51 {
52 get
53 {
54 string text = s_osDescription;
55 if (text == null)
56 {
58 Version version = oSVersion.Version;
59 Span<char> span = stackalloc char[256];
60 string text2;
61 if (!string.IsNullOrEmpty(oSVersion.ServicePack))
62 {
63 IFormatProvider formatProvider = null;
64 IFormatProvider provider = formatProvider;
65 Span<char> span2 = span;
66 Span<char> initialBuffer = span2;
67 DefaultInterpolatedStringHandler handler = new DefaultInterpolatedStringHandler(4, 5, formatProvider, span2);
68 handler.AppendFormatted("Microsoft Windows");
69 handler.AppendLiteral(" ");
70 handler.AppendFormatted((uint)version.Major);
71 handler.AppendLiteral(".");
72 handler.AppendFormatted((uint)version.Minor);
73 handler.AppendLiteral(".");
74 handler.AppendFormatted((uint)version.Build);
75 handler.AppendLiteral(" ");
76 handler.AppendFormatted(oSVersion.ServicePack);
77 text2 = string.Create(provider, initialBuffer, ref handler);
78 }
79 else
80 {
81 IFormatProvider formatProvider = null;
82 IFormatProvider provider2 = formatProvider;
83 Span<char> span2 = span;
84 Span<char> initialBuffer2 = span2;
85 DefaultInterpolatedStringHandler handler2 = new DefaultInterpolatedStringHandler(3, 4, formatProvider, span2);
86 handler2.AppendFormatted("Microsoft Windows");
87 handler2.AppendLiteral(" ");
88 handler2.AppendFormatted((uint)version.Major);
89 handler2.AppendLiteral(".");
90 handler2.AppendFormatted((uint)version.Minor);
91 handler2.AppendLiteral(".");
92 handler2.AppendFormatted((uint)version.Build);
93 text2 = string.Create(provider2, initialBuffer2, ref handler2);
94 }
95 text = text2;
96 s_osDescription = text2;
97 }
98 return text;
99 }
100 }
101
103 {
104 get
105 {
106 int num = s_osArch;
107 if (num == -1)
108 {
109 global::Interop.Kernel32.GetNativeSystemInfo(out var lpSystemInfo);
110 num = (s_osArch = (int)Map((global::Interop.Kernel32.ProcessorArchitecture)lpSystemInfo.wProcessorArchitecture));
111 }
112 return (Architecture)num;
113 }
114 }
115
117 {
118 get
119 {
120 int num = s_processArch;
121 if (num == -1)
122 {
123 global::Interop.Kernel32.GetSystemInfo(out var lpSystemInfo);
124 num = (s_processArch = (int)Map((global::Interop.Kernel32.ProcessorArchitecture)lpSystemInfo.wProcessorArchitecture));
125 }
126 return (Architecture)num;
127 }
128 }
129
130 public static bool IsOSPlatform(OSPlatform osPlatform)
131 {
132 return OperatingSystem.IsOSPlatform(osPlatform.Name);
133 }
134
135 private static Architecture Map(global::Interop.Kernel32.ProcessorArchitecture processorArchitecture)
136 {
137 return processorArchitecture switch
138 {
139 global::Interop.Kernel32.ProcessorArchitecture.Processor_Architecture_ARM64 => Architecture.Arm64,
140 global::Interop.Kernel32.ProcessorArchitecture.Processor_Architecture_ARM => Architecture.Arm,
141 global::Interop.Kernel32.ProcessorArchitecture.Processor_Architecture_AMD64 => Architecture.X64,
142 _ => Architecture.X86,
143 };
144 }
145}
static ? object GetData(string name)
Definition AppContext.cs:31
static OperatingSystem OSVersion
static bool IsOSPlatform(string platform)
static Architecture Map(global::Interop.Kernel32.ProcessorArchitecture processorArchitecture)
static bool IsOSPlatform(OSPlatform osPlatform)
ReadOnlySpan< T > Slice(int start)