public override async Task <Tuple <bool, INuGetResource> > TryCreate(SourceRepository source, CancellationToken token)
        {
            AutoCompleteResourceV2Feed resource = null;

            if (FeedTypeUtility.GetFeedType(source.PackageSource) == FeedType.HttpV2)
            {
                var serviceDocument = await source.GetResourceAsync <ODataServiceDocumentResourceV2>(token);

                var httpSource = await source.GetResourceAsync <HttpSourceResource>(token);

                resource = new AutoCompleteResourceV2Feed(httpSource, serviceDocument.BaseAddress, source.PackageSource);
            }

            return(new Tuple <bool, INuGetResource>(resource != null, resource));
        }
Exemplo n.º 2
0
        public override async Task <Tuple <bool, INuGetResource> > TryCreate(SourceRepository source, CancellationToken token)
        {
            DependencyInfoResource resource = null;

            if ((FeedTypeUtility.GetFeedType(source.PackageSource) & FeedType.HttpV2) != FeedType.None)
            {
                var serviceDocument = await source.GetResourceAsync <ODataServiceDocumentResourceV2>(token);

                var httpSource = await source.GetResourceAsync <HttpSourceResource>(token);

                var parser = new V2FeedParser(httpSource.HttpSource, serviceDocument.BaseAddress, source.PackageSource);

                resource = new DependencyInfoResourceV2Feed(parser, source);
            }

            return(new Tuple <bool, INuGetResource>(resource != null, resource));
        }
        public override Task <Tuple <bool, INuGetResource> > TryCreate(SourceRepository source, CancellationToken token)
        {
            FeedTypeResource curResource = null;

            if (source.FeedTypeOverride == FeedType.Undefined)
            {
                if (!_feedTypeCache.TryGetValue(source.PackageSource, out curResource))
                {
                    lock (_accessLock)
                    {
                        if (!_feedTypeCache.TryGetValue(source.PackageSource, out curResource))
                        {
                            // Check the feed type
                            var feedType = FeedTypeUtility.GetFeedType(source.PackageSource);

                            if (feedType == FeedType.FileSystemUnknown)
                            {
                                // Do not cache unknown folder types
                                curResource = new FeedTypeResource(FeedType.FileSystemUnknown);
                            }
                            else
                            {
                                curResource = new FeedTypeResource(feedType);
                                _feedTypeCache.TryAdd(source.PackageSource, curResource);
                            }
                        }
                    }
                }
            }
            else
            {
                // Use the feed type defined on the source
                curResource = new FeedTypeResource(source.FeedTypeOverride);
            }

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