Пример #1
0
        private MutableIndexChanges Upsert(
            string fullVersion,
            NuGetVersion parsedVersion,
            VersionPropertiesData data)
        {
            var added = new VersionProperties(fullVersion, parsedVersion, data);

            _versionProperties[added.ParsedVersion] = KeyValuePair.Create(added.FullVersion, data);

            // Detect changes related to the latest versions, per search filter.
            var output = new Dictionary <SearchFilters, LatestIndexChanges>();

            foreach (var pair in _versionLists)
            {
                var searchFilter = pair.Key;
                var listState    = pair.Value;
                var predicate    = SearchFilterPredicates[searchFilter];

                LatestIndexChanges latestIndexChanges;
                if (predicate(added))
                {
                    latestIndexChanges = listState.Upsert(added.Filtered);
                }
                else
                {
                    latestIndexChanges = listState.Remove(added.ParsedVersion);
                }

                output[searchFilter] = latestIndexChanges;
            }

            return(MutableIndexChanges.FromLatestIndexChanges(output));
        }
Пример #2
0
 public static MutableIndexChanges Upsert(this VersionLists versionList, VersionProperties version)
 {
     return(versionList.Upsert(version.FullVersion, version.Data));
 }