Beispiel #1
0
 public bool Equals(SemanticVersion other)
 {
     return(!Object.ReferenceEquals(null, other) &&
            Version.Equals(other.Version) &&
            PackageReleaseVersion.Equals(other.PackageReleaseVersion) &&
            SpecialVersion.Equals(other.SpecialVersion, StringComparison.OrdinalIgnoreCase));
 }
Beispiel #2
0
 public bool Equals(SemanticVersion other)
 {
     return(!Object.ReferenceEquals(null, other) &&
            Version.Equals(other.Version) &&
            SpecialVersion.Equals(other.SpecialVersion, StringComparison.OrdinalIgnoreCase) &&
            IsSnapshot == other.IsSnapshot);
 }
Beispiel #3
0
 public override int GetHashCode()
 {
     unchecked
     {
         return(((Version?.GetHashCode() ?? 0) * 397) ^ (SpecialVersion?.GetHashCode() ?? 0));
     }
 }
Beispiel #4
0
        public override int GetHashCode()
        {
            int hashCode = Version.GetHashCode();

            if (SpecialVersion != null)
            {
                hashCode = hashCode * 4567 + SpecialVersion.GetHashCode();
            }

            return(hashCode);
        }
Beispiel #5
0
 public bool EqualsSnapshot(SemanticVersion seekingVersion)
 {
     if (seekingVersion.IsSnapshot)
     {
         return(Version == seekingVersion.Version &&
                SpecialVersion.StartsWith(seekingVersion.SpecialVersion, StringComparison.OrdinalIgnoreCase));
     }
     else
     {
         return(Equals(this, seekingVersion));
     }
 }
Beispiel #6
0
        public override int GetHashCode()
        {
            int hashCode = Version.GetHashCode();

            if (SpecialVersion != null)
            {
                hashCode = hashCode * 4567 + SpecialVersion.GetHashCode();
            }
            if (PackageReleaseVersion != 0)
            {
                hashCode = hashCode * 123 + PackageReleaseVersion.GetHashCode();
            }

            return(hashCode);
        }
Beispiel #7
0
        public int CompareTo(SemanticVersion other)
        {
            if (Object.ReferenceEquals(other, null))
            {
                return(1);
            }

            int result = Version.CompareTo(other.Version);

            if (result != 0)
            {
                return(result);
            }

            bool empty      = String.IsNullOrEmpty(SpecialVersion);
            bool otherEmpty = String.IsNullOrEmpty(other.SpecialVersion);

            if (empty && otherEmpty)
            {
                return(0);
            }
            else if (empty)
            {
                return(1);
            }
            else if (otherEmpty)
            {
                return(-1);
            }

            // Compare the release labels using SemVer 2.0.0 comparision rules.
            var releaseLabels      = SpecialVersion.Split('.');
            var otherReleaseLabels = other.SpecialVersion.Split('.');

            return(CompareReleaseLabels(releaseLabels, otherReleaseLabels));
        }
Beispiel #8
0
 /// <summary>
 /// True if the version contains metadata or multiple release labels.
 /// </summary>
 public bool IsSemVer2()
 {
     return(!string.IsNullOrEmpty(Metadata) ||
            (!string.IsNullOrEmpty(SpecialVersion) && SpecialVersion.Contains(".")));
 }