Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
OperatingSystem.cs
Go to the documentation of this file.
4
5namespace System;
6
8{
9 private readonly Version _version;
10
11 private readonly PlatformID _platform;
12
13 private readonly string _servicePack;
14
15 private string _versionString;
16
18
19 public string ServicePack => _servicePack ?? string.Empty;
20
22
23 public string VersionString
24 {
25 get
26 {
27 if (_versionString == null)
28 {
29 string value = _platform switch
30 {
31 PlatformID.Win32S => "Microsoft Win32S ",
32 PlatformID.Win32Windows => (_version.Major > 4 || (_version.Major == 4 && _version.Minor > 0)) ? "Microsoft Windows 98 " : "Microsoft Windows 95 ",
33 PlatformID.Win32NT => "Microsoft Windows NT ",
34 PlatformID.WinCE => "Microsoft Windows CE ",
35 PlatformID.Unix => "Unix ",
36 PlatformID.Xbox => "Xbox ",
37 PlatformID.MacOSX => "Mac OS X ",
38 PlatformID.Other => "Other ",
39 _ => "<unknown> ",
40 };
41 Span<char> span = stackalloc char[128];
42 string versionString;
43 if (!string.IsNullOrEmpty(_servicePack))
44 {
50 handler.AppendFormatted(value);
52 handler.AppendLiteral(" ");
54 versionString = string.Create(provider, initialBuffer, ref handler);
55 }
56 else
57 {
63 handler2.AppendFormatted(value);
64 handler2.AppendFormatted(_version);
66 }
68 }
69 return _versionString;
70 }
71 }
72
74 : this(platform, version, null)
75 {
76 }
77
79 {
81 {
83 }
84 if (version == null)
85 {
86 throw new ArgumentNullException("version");
87 }
89 _version = version;
91 }
92
97
98 public object Clone()
99 {
101 }
102
103 public override string ToString()
104 {
105 return VersionString;
106 }
107
108 public static bool IsOSPlatform(string platform)
109 {
110 if (platform == null)
111 {
112 throw new ArgumentNullException("platform");
113 }
114 return platform.Equals("WINDOWS", StringComparison.OrdinalIgnoreCase);
115 }
116
117 public static bool IsOSPlatformVersionAtLeast(string platform, int major, int minor = 0, int build = 0, int revision = 0)
118 {
120 {
122 }
123 return false;
124 }
125
126 public static bool IsBrowser()
127 {
128 return false;
129 }
130
131 public static bool IsLinux()
132 {
133 return false;
134 }
135
136 public static bool IsFreeBSD()
137 {
138 return false;
139 }
140
141 public static bool IsFreeBSDVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0)
142 {
143 if (IsFreeBSD())
144 {
145 }
146 return false;
147 }
148
149 public static bool IsAndroid()
150 {
151 return false;
152 }
153
154 public static bool IsAndroidVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0)
155 {
156 if (IsAndroid())
157 {
158 }
159 return false;
160 }
161
162 [SupportedOSPlatformGuard("maccatalyst")]
163 public static bool IsIOS()
164 {
165 return false;
166 }
167
168 [SupportedOSPlatformGuard("maccatalyst")]
169 public static bool IsIOSVersionAtLeast(int major, int minor = 0, int build = 0)
170 {
171 if (IsIOS())
172 {
173 }
174 return false;
175 }
176
177 public static bool IsMacOS()
178 {
179 return false;
180 }
181
182 public static bool IsMacOSVersionAtLeast(int major, int minor = 0, int build = 0)
183 {
184 if (IsMacOS())
185 {
186 }
187 return false;
188 }
189
190 public static bool IsMacCatalyst()
191 {
192 return false;
193 }
194
195 public static bool IsMacCatalystVersionAtLeast(int major, int minor = 0, int build = 0)
196 {
197 if (IsMacCatalyst())
198 {
199 }
200 return false;
201 }
202
203 public static bool IsTvOS()
204 {
205 return false;
206 }
207
208 public static bool IsTvOSVersionAtLeast(int major, int minor = 0, int build = 0)
209 {
210 if (IsTvOS())
211 {
212 }
213 return false;
214 }
215
216 public static bool IsWatchOS()
217 {
218 return false;
219 }
220
221 public static bool IsWatchOSVersionAtLeast(int major, int minor = 0, int build = 0)
222 {
223 if (IsWatchOS())
224 {
225 }
226 return false;
227 }
228
229 public static bool IsWindows()
230 {
231 return true;
232 }
233
234 public static bool IsWindowsVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0)
235 {
236 IsWindows();
238 }
239
240 private static bool IsOSVersionAtLeast(int major, int minor, int build, int revision)
241 {
242 Version version = Environment.OSVersion.Version;
243 if (version.Major != major)
244 {
245 return version.Major > major;
246 }
247 if (version.Minor != minor)
248 {
249 return version.Minor > minor;
250 }
251 if (version.Build != build)
252 {
253 return version.Build > build;
254 }
255 if (version.Revision < revision)
256 {
257 if (version.Revision == -1)
258 {
259 return revision == 0;
260 }
261 return false;
262 }
263 return true;
264 }
265}
static OperatingSystem OSVersion
static bool IsTvOSVersionAtLeast(int major, int minor=0, int build=0)
static bool IsMacCatalystVersionAtLeast(int major, int minor=0, int build=0)
static bool IsIOSVersionAtLeast(int major, int minor=0, int build=0)
OperatingSystem(PlatformID platform, Version version)
static bool IsFreeBSDVersionAtLeast(int major, int minor=0, int build=0, int revision=0)
static bool IsOSVersionAtLeast(int major, int minor, int build, int revision)
static bool IsOSPlatformVersionAtLeast(string platform, int major, int minor=0, int build=0, int revision=0)
static bool IsWindowsVersionAtLeast(int major, int minor=0, int build=0, int revision=0)
static bool IsAndroidVersionAtLeast(int major, int minor=0, int build=0, int revision=0)
static bool IsOSPlatform(string platform)
static bool IsMacOSVersionAtLeast(int major, int minor=0, int build=0)
readonly string _servicePack
override string ToString()
void GetObjectData(SerializationInfo info, StreamingContext context)
OperatingSystem(PlatformID platform, Version version, string servicePack)
static bool IsWatchOSVersionAtLeast(int major, int minor=0, int build=0)
readonly Version _version
readonly PlatformID _platform
static string Arg_EnumIllegalVal
Definition SR.cs:144
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
Definition SR.cs:7
override string ToString()
Definition Version.cs:220