Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
RuntimeInformation.cs
Go to the documentation of this file.
1
using
System.Reflection
;
2
using
System.Runtime.CompilerServices
;
3
4
namespace
System.Runtime.InteropServices
;
5
6
public
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
}
32
return
s_frameworkDescription
;
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"
;
44
s_runtimeIdentifier
= (
string
)
obj
;
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
{
57
OperatingSystem
oSVersion =
Environment
.
OSVersion
;
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
102
public
static
Architecture
OSArchitecture
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
116
public
static
Architecture
ProcessArchitecture
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
}
System.AppContext.GetData
static ? object GetData(string name)
Definition
AppContext.cs:31
System.AppContext
Definition
AppContext.cs:14
System.Environment.OSVersion
static OperatingSystem OSVersion
Definition
Environment.cs:205
System.Environment
Definition
Environment.cs:15
System.OperatingSystem.Version
Version Version
Definition
OperatingSystem.cs:21
System.OperatingSystem.IsOSPlatform
static bool IsOSPlatform(string platform)
Definition
OperatingSystem.cs:108
System.OperatingSystem.ServicePack
string ServicePack
Definition
OperatingSystem.cs:19
System.OperatingSystem
Definition
OperatingSystem.cs:8
System.Reflection.AssemblyInformationalVersionAttribute
Definition
AssemblyInformationalVersionAttribute.cs:5
System.Runtime.InteropServices.RuntimeInformation.s_frameworkDescription
static string s_frameworkDescription
Definition
RuntimeInformation.cs:8
System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription
static string FrameworkDescription
Definition
RuntimeInformation.cs:19
System.Runtime.InteropServices.RuntimeInformation.RuntimeIdentifier
static string RuntimeIdentifier
Definition
RuntimeInformation.cs:37
System.Runtime.InteropServices.RuntimeInformation.s_osArch
static volatile int s_osArch
Definition
RuntimeInformation.cs:14
System.Runtime.InteropServices.RuntimeInformation.Map
static Architecture Map(global::Interop.Kernel32.ProcessorArchitecture processorArchitecture)
Definition
RuntimeInformation.cs:135
System.Runtime.InteropServices.RuntimeInformation.OSArchitecture
static Architecture OSArchitecture
Definition
RuntimeInformation.cs:103
System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture
static Architecture ProcessArchitecture
Definition
RuntimeInformation.cs:117
System.Runtime.InteropServices.RuntimeInformation.OSDescription
static string OSDescription
Definition
RuntimeInformation.cs:51
System.Runtime.InteropServices.RuntimeInformation.s_processArch
static volatile int s_processArch
Definition
RuntimeInformation.cs:16
System.Runtime.InteropServices.RuntimeInformation.s_osDescription
static string s_osDescription
Definition
RuntimeInformation.cs:12
System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform
static bool IsOSPlatform(OSPlatform osPlatform)
Definition
RuntimeInformation.cs:130
System.Runtime.InteropServices.RuntimeInformation.s_runtimeIdentifier
static string s_runtimeIdentifier
Definition
RuntimeInformation.cs:10
System.Runtime.InteropServices.RuntimeInformation
Definition
RuntimeInformation.cs:7
System.Version.Build
int Build
Definition
Version.cs:23
System.Version.Minor
int Minor
Definition
Version.cs:21
System.Version.Major
int Major
Definition
Version.cs:19
System.Version
Definition
Version.cs:10
string
System.IFormatProvider
Definition
IFormatProvider.cs:4
System.Reflection
Definition
ICustomTypeProvider.cs:1
System.Runtime.CompilerServices
Definition
NullablePublicOnlyAttribute.cs:3
System.Runtime.InteropServices.Architecture
Architecture
Definition
Architecture.cs:4
System.Runtime.InteropServices
Definition
SequenceMarshal.cs:4
System.ExceptionArgument.text
@ text
System.ExceptionArgument.obj
@ obj
System.ReadOnlySpan.IsEmpty
bool IsEmpty
Definition
ReadOnlySpan.cs:79
System.ReadOnlySpan.Slice
ReadOnlySpan< T > Slice(int start)
Definition
ReadOnlySpan.cs:232
System.ReadOnlySpan
Definition
ReadOnlySpan.cs:14
System.Runtime.CompilerServices.DefaultInterpolatedStringHandler.AppendLiteral
void AppendLiteral(string value)
Definition
DefaultInterpolatedStringHandler.cs:78
System.Runtime.CompilerServices.DefaultInterpolatedStringHandler.AppendFormatted
void AppendFormatted(ReadOnlySpan< char > value)
Definition
DefaultInterpolatedStringHandler.cs:210
System.Runtime.CompilerServices.DefaultInterpolatedStringHandler
Definition
DefaultInterpolatedStringHandler.cs:10
System.Runtime.InteropServices.OSPlatform.Name
string Name
Definition
OSPlatform.cs:19
System.Runtime.InteropServices.OSPlatform
Definition
OSPlatform.cs:6
System.Span
Definition
Span.cs:14
source
System.Runtime.InteropServices.RuntimeInformation
System.Runtime.InteropServices
RuntimeInformation.cs
Generated by
1.10.0