Beispiel #1
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Major;
         hashCode = (hashCode * 397) ^ Minor;
         hashCode = (hashCode * 397) ^ Patch;
         hashCode = (hashCode * 397) ^ (PreRelease != null ? PreRelease.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Original != null ? Original.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (PreReleaseBuild != null ? PreReleaseBuild.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Build != null ? Build.GetHashCode() : 0);
         return(hashCode);
     }
 }
Beispiel #2
0
        public static SemVer Create(string version)
        {
            var dashSplitted = version.Split('-', '+');
            var splitted     = dashSplitted[0].Split('.');
            var l            = splitted.Length;

            var prereleaseBuild = dashSplitted.Length > 1 && dashSplitted[1].Split('.').Length > 1 ? dashSplitted[1].Split('.')[1] : "0";

            return(new SemVer
            {
                Major = l > 0 ? Int32.Parse(splitted[0]) : 0,
                Minor = l > 1 ? Int32.Parse(splitted[1]) : 0,
                Patch = l > 2 ? Int32.Parse(splitted[2]) : 0,
                PreRelease = PreRelease.TryParse(dashSplitted.Length > 1 ? dashSplitted[1].Split('.')[0] : String.Empty),
                Build = l > 3 ? splitted[3] : "0",
                PreReleaseBuild = prereleaseBuild,
                Original = version
            });
        }