public static ExchangeObjectVersion Parse(string input) { if (input == null || string.IsNullOrEmpty(input = input.Trim())) { throw new ArgumentException(DataStrings.EmptyExchangeObjectVersion, "input"); } long encodedVersion = 0L; if (long.TryParse(input, out encodedVersion)) { return(new ExchangeObjectVersion(encodedVersion)); } if (ExchangeObjectVersion.parsingRegex == null) { lock (ExchangeObjectVersion.parsingRegexInitializationLock) { if (ExchangeObjectVersion.parsingRegex == null) { ExchangeObjectVersion.parsingRegex = new Regex("^(?<major>\\d{1,3})\\.(?<minor>\\d{1,3})\\s*\\((?<exbuild>.+)\\)$", RegexOptions.ExplicitCapture | RegexOptions.Compiled); } } } Match match = ExchangeObjectVersion.parsingRegex.Match(input); if (!match.Success) { throw new ArgumentException(DataStrings.InvalidFormatExchangeObjectVersion); } byte major = 0; if (!byte.TryParse(match.Groups["major"].Value, out major)) { throw new ArgumentException(DataStrings.InvalidFormatExchangeObjectVersion); } byte minor = 0; if (!byte.TryParse(match.Groups["minor"].Value, out minor)) { throw new ArgumentException(DataStrings.InvalidFormatExchangeObjectVersion); } ExchangeBuild exchangeBuild = ExchangeBuild.Parse(match.Groups["exbuild"].Value); return(new ExchangeObjectVersion(major, minor, exchangeBuild.Major, exchangeBuild.Minor, exchangeBuild.Build, exchangeBuild.BuildRevision)); }
public ExchangeObjectVersion(byte major, byte minor, ExchangeBuild exchangeBuild) { this.Major = major; this.Minor = minor; this.ExchangeBuild = exchangeBuild; }