public static bool TryParse(UInt32 value, out SoftwareVersion version) { version = null; String strValue = value.ToString(); int major, minor, revision, build; /** start at the back and work forward */ int offset = strValue.Length - 1; if (offset > 3 && int.TryParse(strValue.Substring(offset - 2, 3), out build)) { offset -= 3; if (offset > 2 && int.TryParse(strValue.Substring(offset - 1, 2), out revision)) { offset -= 2; if (offset >= 2 && int.TryParse(strValue.Substring(offset - 1, 2), out minor)) { offset = offset == 3 ? 2 : 1; if (offset >= 0 && int.TryParse(strValue.Substring(0, offset), out major)) { version = new SoftwareVersion(major, minor, revision, build); } } } } return(version != null); }
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { SoftwareVersion version = null; string valueString = value as string; if (valueString != null) { version = new SoftwareVersion(valueString); } else { version = new SoftwareVersion(); } return(version); }
public static bool TryFindInString(String input, out SoftwareVersion version) { version = null; int offset, length; if (TryFindInString(input, out offset, out length)) { String temp = input.Substring(offset, length); if (SoftwareVersion.TryParse(temp, out version) == false) { version = null; } } return(version != null); }
public static bool TryParseUDS(String major, out SoftwareVersion version) { bool result = false; version = null; try { version = new SoftwareVersion(); result = version.ParseUDS(major); } catch (Exception) { } return(result); }
static bool TryGetVersion(String fileName, out SoftwareVersion version) { version = null; int dashIndex = 0; String versionPart = Path.GetFileNameWithoutExtension(fileName); if ((dashIndex = versionPart.IndexOf('-')) != -1) { versionPart = versionPart.Substring(dashIndex + 1); if (SoftwareVersion.IsValid(versionPart)) { version = new SoftwareVersion(versionPart); } } return(version != null); }
public static bool TryParse(String str, out SoftwareVersion version) { version = new SoftwareVersion(); return(version.Parse(str, false)); }
public static SoftwareVersion Parse(String str) { SoftwareVersion version = new SoftwareVersion(str); return(version); }