예제 #1
0
        public PackageSet Clone()
        {
            var newSet = new PackageSet();

            newSet.Index.UnionWith(Index);

            return(newSet);
        }
예제 #2
0
        private async Task CreateIndexAsync(string id, PackageSet packageSet)
        {
            // Get all versions
            var packages = await packageSet.GetPackagesByIdAsync(id);

            var versions = new SortedSet <NuGetVersion>(packages.Select(e => e.Version));

            await CreateIndexAsync(id, versions);
        }
예제 #3
0
        private static PackageSet GetPackageSetFromJson(JObject packagesNode)
        {
            var result = new PackageSet();

            foreach (var property in packagesNode.Properties())
            {
                var versions = (JArray)property.Value;
                var id       = property.Name;

                foreach (var versionEntry in versions)
                {
                    var packageVersion = NuGetVersion.Parse(versionEntry.ToObject <string>());
                    result.Index.Add(new PackageIdentity(id, packageVersion));
                }
            }

            return(result);
        }
예제 #4
0
        private static JObject CreatePackageSetJson(PackageSet packages)
        {
            var json = new JObject();

            var groups = packages.Index.GroupBy(e => e.Id, StringComparer.OrdinalIgnoreCase).ToList();

            foreach (var group in groups.OrderBy(e => e.Key, StringComparer.OrdinalIgnoreCase))
            {
                var versionArray = new JArray(group.OrderByDescending(e => e.Version)
                                              .Select(e => e.Version.ToFullString()));

                if (versionArray.Count > 0)
                {
                    json.Add(group.Key, versionArray);
                }
            }

            return(json);
        }