public static bool TryParse(string input, out Version result) { Version.VersionResult versionResult = default(Version.VersionResult); versionResult.Init("input", false); bool result2 = Version.TryParseVersion(input, ref versionResult); result = versionResult.m_parsedVersion; return(result2); }
public static bool TryParse(string input, out Version result) { Version.VersionResult result1 = new Version.VersionResult(); result1.Init("input", false); int num = Version.TryParseVersion(input, ref result1) ? 1 : 0; result = result1.m_parsedVersion; return(num != 0); }
// Token: 0x060015AB RID: 5547 RVA: 0x00040018 File Offset: 0x0003E218 private static bool TryParseVersion(string version, ref Version.VersionResult result) { if (version == null) { result.SetFailure(Version.ParseFailureKind.ArgumentNullException); return(false); } string[] array = version.Split(Version.SeparatorsArray); int num = array.Length; if (num < 2 || num > 4) { result.SetFailure(Version.ParseFailureKind.ArgumentException); return(false); } int major; if (!Version.TryParseComponent(array[0], "version", ref result, out major)) { return(false); } int minor; if (!Version.TryParseComponent(array[1], "version", ref result, out minor)) { return(false); } num -= 2; if (num > 0) { int build; if (!Version.TryParseComponent(array[2], "build", ref result, out build)) { return(false); } num--; if (num > 0) { int revision; if (!Version.TryParseComponent(array[3], "revision", ref result, out revision)) { return(false); } result.m_parsedVersion = new Version(major, minor, build, revision); } else { result.m_parsedVersion = new Version(major, minor, build); } } else { result.m_parsedVersion = new Version(major, minor); } return(true); }
private static bool TryParseVersion(string version, ref Version.VersionResult result) { if (version == null) { result.SetFailure(Version.ParseFailureKind.ArgumentNullException); return(false); } string[] strArray = version.Split(Version.SeparatorsArray); int length = strArray.Length; if (length < 2 || length > 4) { result.SetFailure(Version.ParseFailureKind.ArgumentException); return(false); } int parsedComponent1; int parsedComponent2; if (!Version.TryParseComponent(strArray[0], "version", ref result, out parsedComponent1) || !Version.TryParseComponent(strArray[1], "version", ref result, out parsedComponent2)) { return(false); } int num = length - 2; if (num > 0) { int parsedComponent3; if (!Version.TryParseComponent(strArray[2], "build", ref result, out parsedComponent3)) { return(false); } if (num - 1 > 0) { int parsedComponent4; if (!Version.TryParseComponent(strArray[3], "revision", ref result, out parsedComponent4)) { return(false); } result.m_parsedVersion = new Version(parsedComponent1, parsedComponent2, parsedComponent3, parsedComponent4); } else { result.m_parsedVersion = new Version(parsedComponent1, parsedComponent2, parsedComponent3); } } else { result.m_parsedVersion = new Version(parsedComponent1, parsedComponent2); } return(true); }
public static Version Parse(string input) { if (input == null) { throw new ArgumentNullException("input"); } Version.VersionResult versionResult = default(Version.VersionResult); versionResult.Init("input", true); if (!Version.TryParseVersion(input, ref versionResult)) { throw versionResult.GetVersionParseException(); } return(versionResult.m_parsedVersion); }
// Token: 0x060015AC RID: 5548 RVA: 0x000400F0 File Offset: 0x0003E2F0 private static bool TryParseComponent(string component, string componentName, ref Version.VersionResult result, out int parsedComponent) { if (!int.TryParse(component, NumberStyles.Integer, CultureInfo.InvariantCulture, out parsedComponent)) { result.SetFailure(Version.ParseFailureKind.FormatException, component); return(false); } if (parsedComponent < 0) { result.SetFailure(Version.ParseFailureKind.ArgumentOutOfRangeException, componentName); return(false); } return(true); }