示例#1
0
        /// <summary>
        /// Merges another packageIndex into this package index.  For any overlapping
        /// data 'other' has precedence.
        /// </summary>
        /// <param name="other"></param>
        public void Merge(PackageIndex other)
        {
            if (other.IndexSources.IsSubsetOf(IndexSources))
            {
                return;
            }

            // if pre-release is set on this index and different than the other
            // move pre-release to individual infos
            if (PreRelease != null && !PreRelease.Equals(other.PreRelease))
            {
                foreach (var info in Packages.Values)
                {
                    if (info.PreRelease == null)
                    {
                        info.PreRelease = PreRelease;
                    }
                }

                PreRelease = null;
            }

            foreach (var otherPackage in other.Packages)
            {
                var         otherInfo = otherPackage.Value;
                PackageInfo info;

                if (Packages.TryGetValue(otherPackage.Key, out info))
                {
                    info.Merge(otherInfo);
                }
                else
                {
                    Packages[otherPackage.Key] = info = otherInfo;

                    // if pre-release is set on the other index and doesn't match the value of the info, set it
                    if (other.PreRelease != null && !other.PreRelease.Equals(info.PreRelease))
                    {
                        info.PreRelease = other.PreRelease;
                    }
                }
            }

            foreach (var otherModuleToPackage in other.ModulesToPackages)
            {
                ModulesToPackages[otherModuleToPackage.Key] = otherModuleToPackage.Value;
            }

            MetaPackages.Merge(other.MetaPackages);

            foreach (var otherIndexSource in other.IndexSources)
            {
                IndexSources.Add(otherIndexSource);
            }
        }
 /// <summary>
 /// Determines whether two <see cref="SemanticVersion"/> instances are equal.
 /// </summary>
 /// <param name="obj">The object to compare with the current <see cref="SemanticVersion"/>.</param>
 /// <returns>'true' if the specified object is equal to the current <see cref="SemanticVersion"/>; otherwise, 'false'.</returns>
 public override bool Equals(object obj)
 {
     if (obj is SemanticVersion other)
     {
         bool sameVersions = Major == other.Major &&
                             Minor == other.Minor &&
                             Patch == other.Patch;
         if (sameVersions && HasPreRelease && other.HasPreRelease)
         {
             if (PreRelease.Equals(other.PreRelease) && HasBuildMetadata && other.HasBuildMetadata)
             {
                 return(BuildMetadata.Equals(other.BuildMetadata));
             }
         }
     }
     return(false);
 }