Beispiel #1
0
        /// <summary>
        /// Has to be in this format: m.n.b.r
        /// </summary>
        /// <param name="version"></param>
        /// <returns></returns>
        public static VersionSystem Parse(string version)
        {
            VersionSystem _v = new VersionSystem();

            if (version[1] != '.')
            {
                version = version.Insert(1, ".");
            }
            string[] _s = version.Split(new char[] { '.' }, 4);

            _v.Major = int.Parse(_s[1]);
            _v.Minor = int.Parse(_s[2]);

            if (_s[3].Contains("-"))
            {
                string[] _b_r = _s[3].Split('-');
                _v.Build    = int.Parse(_b_r[0]);
                _v.Revision = _b_r[1];
            }
            else
            {
                _v.Build    = int.Parse(_s[3]);
                _v.Revision = string.Empty;
            }
            return(_v);
        }
Beispiel #2
0
 public static string ToString(VersionSystem version)
 {
     if (!string.IsNullOrEmpty(version.Revision))
     {
         return(string.Format("v.{0}.{1}.{2}-{3}", version.Major, version.Minor, version.Build, version.Revision));
     }
     else
     {
         return(string.Format("v.{0}.{1}.{2}", version.Major, version.Minor, version.Build));
     }
 }
Beispiel #3
0
        public static bool Compare(VersionSystem v1, VersionSystem v2)
        {
            bool equal = false;

            Console.WriteLine("v1:{0}-v2:{1}", v1.ToString(), v2.ToString());
            if (v1.Major == v2.Major && v1.Minor == v2.Minor && v1.Build == v2.Build && v1.Revision == v2.Revision)
            {
                equal = true;
            }

            return(equal);
        }
Beispiel #4
0
        public static VersionSystem ParseFromLocalAssembly(string version)
        {
            VersionSystem versionSystem = new VersionSystem();

            string[] versions = version.Split('.');
            versionSystem.Major = int.Parse(versions[0]);
            versionSystem.Minor = int.Parse(versions[1]);
            versionSystem.Build = int.Parse(versions[2]);

            if (versions[3].StartsWith("0")) // If start with [0] is null
            {
                versionSystem.Revision = string.Empty;
            }

            if (versions[3].StartsWith("1")) // If start with [1] is Alpha
            {
                string rev = versions[3].Remove(0, 1);
                if (rev != string.Empty)
                {
                    string revision = string.Format("alpha.{0}", rev);
                    versionSystem.Revision = revision;
                }
                else
                {
                    versionSystem.Revision = "alpha";
                }
            }
            if (versions[3].StartsWith("2")) // If start with [2] is Beta
            {
                string rev = versions[3].Remove(0, 1);
                if (rev != string.Empty)
                {
                    string revision = string.Format("beta.{0}", rev);
                    versionSystem.Revision = revision;
                }
                else
                {
                    versionSystem.Revision = "beta";
                }
            }


            return(versionSystem);
        }