| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- using Microsoft.Office.Interop.Excel;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Fuel01
- {
- public class Version
- {
- public Version(int principal, int secondary, int revision, int build)
- {
- Principal = principal;
- Secondary = secondary;
- Revision = revision;
- Build = build;
- }
- public Version(string version)
- {
- var versionDetails = version.Split('.');
- if (versionDetails.Length == 4)
- {
- Principal = Convert.ToInt32(versionDetails[0]);
- Secondary = Convert.ToInt32(versionDetails[1]);
- Revision = Convert.ToInt32(versionDetails[2]);
- Build = Convert.ToInt32(versionDetails[3]);
- }
- }
- public Version(string principal, string secondary, string revision, string build)
- {
- Principal = Convert.ToInt32(principal);
- Secondary = Convert.ToInt32(secondary);
- Revision = Convert.ToInt32(revision);
- Build = Convert.ToInt32(build);
- }
- public int Build { get; set; }
- public int Principal { get; set; }
- public int Revision { get; set; }
- public int Secondary { get; set; }
- public static double MakeVersionCompareNumber(double v1, double v2, double v3, double v4)
- => v1 * Math.Pow(10, 9) + v2 * Math.Pow(10, 6) + v3 * Math.Pow(10, 3) + v4;
- public static string NextVersion(int principal, int secondary, int revision, int build)
- {
- if (build < 98)
- {
- build = 0;
- revision++;
- }
- else
- {
- build++;
- }
- if (revision == 100)
- {
- revision = 0;
- secondary ++;
- }
- if (secondary == 100)
- {
- secondary = 0;
- principal ++;
- }
- return VersionString(principal, secondary, revision, build);
- }
- public static string NextVersion(string version)
- {
- var versionDetails = version.Split('.');
- if (versionDetails.Length == 4)
- {
- var ver2 = new Version(versionDetails[0], versionDetails[1], versionDetails[2], versionDetails[3]);
- var ver3 = NextVersion(ver2);
- return ver3;
- }
- else
- {
- return string.Empty;
- }
- }
- public static string NextVersion(Version version)
- {
- return NextVersion(version.Principal, version.Secondary, version.Revision, version.Build);
- }
- public static string VersionString(string p, string s, string r, string b) => $"{p}.{s}.{r}.{b}";
- public static string VersionString(int p, int s, int r, int b) => $"{p}.{s}.{r}.{b}";
- public Version NextVersion()
- {
- if (Build < 98)
- {
- Build++;
- return this;
- }
- else
- {
- Build = 0;
- Revision++;
- }
- if (Revision == 100)
- {
- Revision = 0;
- Secondary++;
- }
- if (Secondary == 100)
- {
- Secondary = 0;
- Principal++;
- }
- return this;
- }
- public override string ToString() => $"{Principal}.{Secondary}.{Revision}.{Build}";
- public bool VersionIsSup(Version v1)
- {
- return MakeVersionCompareNumber(Principal, Secondary, Revision, Build) > MakeVersionCompareNumber(v1.Principal, v1.Secondary, v1.Revision, v1.Build);
- }
- }
- }
|