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

            var v2repo = await GetRepository(source, token);

            if (v2repo != null &&
                v2repo.V2Client != null &&
                !string.IsNullOrEmpty(v2repo.V2Client.Source))
            {
                // For a V2 package source, the source url is the list endpoint as well
                listCommandResource = new ListCommandResource(v2repo.V2Client.Source);
            }

            var result = new Tuple <bool, INuGetResource>(listCommandResource != null, listCommandResource);

            return(result);
        }
        public override async Task <Tuple <bool, INuGetResource> > TryCreate(
            SourceRepository source,
            CancellationToken token)
        {
            ListCommandResource listCommandResource = null;

            var serviceIndex = await source.GetResourceAsync <ServiceIndexResourceV3>(token);

            if (serviceIndex != null)
            {
                // Since it is a v3 package source, always return a ListCommandResource object
                // which may or may not contain a list endpoint.
                // Returning null here will result in ListCommandResource
                // getting returned for this very v3 package source as if it was a v2 package source
                var baseUrl = serviceIndex[ServiceTypes.LegacyGallery].FirstOrDefault();
                listCommandResource = new ListCommandResource(baseUrl?.AbsoluteUri);
            }

            var result = new Tuple <bool, INuGetResource>(listCommandResource != null, listCommandResource);

            return(result);
        }