/// <summary> /// Initializes a new instance of the <see cref="UpdateVersion" />-class. /// </summary> /// <param name="major">The major version.</param> /// <param name="minor">The minor version.</param> /// <param name="build">The build version.</param> /// <param name="revision">The revision version.</param> /// <param name="devStage">The developmental stage.</param> /// <param name="developmentBuild">The pre-release version.</param> public UpdateVersion(int major, int minor, int build, int revision, DevelopmentalStage devStage, int developmentBuild) { if (major < 0) { throw new ArgumentOutOfRangeException("major", "Index must be 0 or higher"); } if (minor < 0) { throw new ArgumentOutOfRangeException("minor", "Index must be 0 or higher"); } if (build < 0) { throw new ArgumentOutOfRangeException("build", "Index must be 0 or higher"); } if (revision < 0) { throw new ArgumentOutOfRangeException("revision", "Index must be 0 or higher"); } Major = major; Minor = minor; Build = build; Revision = revision; DevelopmentalStage = devStage; DevelopmentBuild = developmentBuild; }
/// <summary> /// Returns a new <see cref="UpdateVersion"/> from the given full text. /// </summary> /// <param name="fullText">The full text containing the version information.</param> /// <returns>Returns a new <see cref="UpdateVersion"/> from the given full text.</returns> /// <exception cref="System.ArgumentException">fullText</exception> public static UpdateVersion FromFullText(string fullText) { var versionSections = fullText.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (versionSections.Length != 1 && versionSections.Length != 3) throw new ArgumentException("fullText"); var versionParts = versionSections[0].Split('.'); int major = int.Parse(versionParts[0]); int minor = int.Parse(versionParts[1]); int build = int.Parse(versionParts[2]); int revision = int.Parse(versionParts[3]); if (versionSections.Length == 1) return new UpdateVersion(major, minor, build, revision); DevelopmentalStage devStage = DevelopmentalStage.Release; switch (versionSections[1]) { case "Alpha": devStage = DevelopmentalStage.Alpha; break; case "Beta:": devStage = DevelopmentalStage.Beta; break; } int developmentBuild = int.Parse(versionSections[2]); return new UpdateVersion(major, minor, build, revision, devStage, developmentBuild); }
// Overwritten Instance Methods /// <summary> /// Returns a <see cref="System.String" /> that represents this instance. /// </summary> public override string ToString() { if (DevelopmentalStage != DevelopmentalStage.Release) { return(String.Format("{0}.{1}.{2}.{3}{4}{5}", Major, Minor, Build, Revision, DevelopmentalStage.ToString().Substring(0, 1).ToLower(), DevelopmentBuild)); } return(BasicVersion); }
private void developmentalStageComboBox_SelectedIndexChanged(object sender, EventArgs e) { _developmentalStage = (DevelopmentalStage) Enum.Parse(typeof (DevelopmentalStage), developmentalStageComboBox.GetItemText(developmentalStageComboBox.SelectedItem)); if (_developmentalStage == DevelopmentalStage.Alpha || _developmentalStage == DevelopmentalStage.Beta || _developmentalStage == DevelopmentalStage.ReleaseCandidate) developmentBuildNumericUpDown.Enabled = true; else developmentBuildNumericUpDown.Enabled = false; }