Ejemplo n.º 1
0
        private async Task <bool> CompleteTaskAsync(Task <JObject> task, ReferenceCache cache, ConcurrentBag <CatalogEntry> entries)
        {
            var json = await task;

            foreach (var item in json["items"])
            {
                // Store the url in pieces so it can be cached.
                // Split on /
                var urlParts = item["@id"]
                               .ToObject <string>().Split('/')
                               .Select(s => cache.GetString(s))
                               .ToArray();

                var entry = new CatalogEntry(
                    urlParts,
                    cache.GetString(item["@type"].ToObject <string>()),
                    cache.GetString(item["commitId"].ToObject <string>()),
                    cache.GetDate(item["commitTimeStamp"].ToObject <string>()),
                    cache.GetString(item["nuget:id"].ToObject <string>()),
                    cache.GetVersion(item["nuget:version"].ToObject <string>()),
                    _serviceIndex,
                    GetJson,
                    GetNuspec,
                    GetNupkg);

                entries.Add(entry);
            }

            return(true);
        }
Ejemplo n.º 2
0
        private List <CatalogEntry> GetEntriesFromJson(JObject json, ReferenceCache cache)
        {
            var entries = new List <CatalogEntry>();

            foreach (var item in json["items"])
            {
                // Store the url in pieces so it can be cached.
                // Split on /
                var urlParts = item["@id"]
                               .ToObject <string>().Split('/')
                               .Select(s => cache.GetString(s))
                               .ToArray();

                var entry = new CatalogEntry(
                    urlParts,
                    cache.GetString(item["@type"].ToObject <string>()),
                    cache.GetString(item["commitId"].ToObject <string>()),
                    cache.GetDate(item["commitTimeStamp"].ToObject <string>()),
                    cache.GetString(item["nuget:id"].ToObject <string>()),
                    cache.GetVersion(item["nuget:version"].ToObject <string>()),
                    _serviceIndex,
                    GetJson,
                    GetNuspec,
                    GetNupkg);

                entries.Add(entry);
            }

            return(entries);
        }