示例#1
0
        public override async Task <Tuple <bool, INuGetResource> > TryCreate(SourceRepository source, CancellationToken token)
        {
            PackageSearchResourceV3 curResource = null;
            var serviceIndex = await source.GetResourceAsync <ServiceIndexResourceV3>(token);

            if (serviceIndex != null)
            {
                var rawSearch = await source.GetResourceAsync <RawSearchResourceV3>(token);

                curResource = new PackageSearchResourceV3(rawSearch);
            }

            return(new Tuple <bool, INuGetResource>(curResource != null, curResource));
        }
        public override async Task <Tuple <bool, INuGetResource> > TryCreate(SourceRepository source, CancellationToken token)
        {
            PackageSearchResourceV3 curResource = null;
            var serviceIndex = await source.GetResourceAsync <ServiceIndexResourceV3>(token);

            if (serviceIndex != null)
            {
                var endpoints          = serviceIndex.GetServiceEntryUris(ServiceTypes.SearchQueryService);
                var httpSourceResource = await source.GetResourceAsync <HttpSourceResource>(token);

                // construct a new resource
                curResource = new PackageSearchResourceV3(httpSourceResource.HttpSource, endpoints);
            }

            return(new Tuple <bool, INuGetResource>(curResource != null, curResource));
        }