Esempio n. 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));
 }
Esempio n. 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);
 }
Esempio n. 3
0
 public override int GetHashCode()
 {
     unchecked
     {
         return(((Version?.GetHashCode() ?? 0) * 397) ^ (SpecialVersion?.GetHashCode() ?? 0));
     }
 }
Esempio n. 4
0
        public override int GetHashCode()
        {
            int hashCode = Version.GetHashCode();

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

            return(hashCode);
        }
Esempio n. 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));
     }
 }
Esempio n. 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);
        }
Esempio n. 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));
        }
Esempio n. 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(".")));
 }