Terraria v1.4.4.9
Terraria source code documentation
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros

◆ ParseVersion()

static Version System.Version.ParseVersion ( ReadOnlySpan< char > input,
bool throwOnFailure )
inlinestaticprivate

Definition at line 339 of file Version.cs.

340 {
341 int num = input.IndexOf('.');
342 if (num < 0)
343 {
344 if (throwOnFailure)
345 {
346 throw new ArgumentException(SR.Arg_VersionString, "input");
347 }
348 return null;
349 }
350 int num2 = -1;
351 int num3 = input.Slice(num + 1).IndexOf('.');
352 if (num3 != -1)
353 {
354 num3 += num + 1;
355 num2 = input.Slice(num3 + 1).IndexOf('.');
356 if (num2 != -1)
357 {
358 num2 += num3 + 1;
359 if (input.Slice(num2 + 1).Contains('.'))
360 {
361 if (throwOnFailure)
362 {
363 throw new ArgumentException(SR.Arg_VersionString, "input");
364 }
365 return null;
366 }
367 }
368 }
369 if (!TryParseComponent(input.Slice(0, num), "input", throwOnFailure, out var parsedComponent))
370 {
371 return null;
372 }
373 int parsedComponent2;
374 if (num3 != -1)
375 {
376 if (!TryParseComponent(input.Slice(num + 1, num3 - num - 1), "input", throwOnFailure, out parsedComponent2))
377 {
378 return null;
379 }
380 int parsedComponent3;
381 if (num2 != -1)
382 {
383 if (!TryParseComponent(input.Slice(num3 + 1, num2 - num3 - 1), "build", throwOnFailure, out parsedComponent3) || !TryParseComponent(input.Slice(num2 + 1), "revision", throwOnFailure, out var parsedComponent4))
384 {
385 return null;
386 }
387 return new Version(parsedComponent, parsedComponent2, parsedComponent3, parsedComponent4);
388 }
389 if (!TryParseComponent(input.Slice(num3 + 1), "build", throwOnFailure, out parsedComponent3))
390 {
391 return null;
392 }
393 return new Version(parsedComponent, parsedComponent2, parsedComponent3);
394 }
395 if (!TryParseComponent(input.Slice(num + 1), "input", throwOnFailure, out parsedComponent2))
396 {
397 return null;
398 }
399 return new Version(parsedComponent, parsedComponent2);
400 }
static bool TryParseComponent(ReadOnlySpan< char > component, string componentName, bool throwOnFailure, out int parsedComponent)
Definition Version.cs:402

References System.Version.Version(), System.SR.Arg_VersionString, System.input, and System.Version.TryParseComponent().

Referenced by System.Version.Parse(), System.Version.Parse(), System.Version.TryParse(), and System.Version.TryParse().