public static string GetRequiredResourceUrl(this ServiceIndexResponse serviceIndex, string[] types, string resourceName)
        {
            // For more information on required resources,
            // see: https://docs.microsoft.com/en-us/nuget/api/overview#resources-and-schema
            var resourceUrl = serviceIndex.GetResourceUrl(types);

            if (string.IsNullOrEmpty(resourceUrl))
            {
                throw new InvalidOperationException(
                          $"The service index does not have a resource named '{resourceName}'");
            }

            return(resourceUrl);
        }
Esempio n. 2
0
        public static string GetResourceUrl(this ServiceIndexResponse serviceIndex, string[] types)
        {
            var resource = types.SelectMany(t => serviceIndex.Resources.Where(r => r.Type == t)).FirstOrDefault();

            return(resource?.ResourceUrl.Trim('/'));
        }
Esempio n. 3
0
 public static string GetSearchAutocompleteResourceUrl(this ServiceIndexResponse serviceIndex)
 {
     return(serviceIndex.GetResourceUrl(SearchAutocompleteService));
 }
Esempio n. 4
0
 public static string GetSearchQueryResourceUrl(this ServiceIndexResponse serviceIndex)
 {
     return(serviceIndex.GetResourceUrl(SearchQueryService));
 }
Esempio n. 5
0
 public static string GetCatalogResourceUrl(this ServiceIndexResponse serviceIndex)
 {
     return(serviceIndex.GetResourceUrl(Catalog));
 }
Esempio n. 6
0
 public static string GetPackageMetadataResourceUrl(this ServiceIndexResponse serviceIndex)
 {
     return(serviceIndex.GetResourceUrl(RegistrationsBaseUrl));
 }
Esempio n. 7
0
 public static string GetPackageContentResourceUrl(this ServiceIndexResponse serviceIndex)
 {
     return(serviceIndex.GetResourceUrl(PackageBaseAddress));
 }
Esempio n. 8
0
 private UrlGeneratorClient(ServiceIndexResponse serviceIndex)
 {
     _serviceIndex = serviceIndex ?? throw new ArgumentNullException(nameof(serviceIndex));
 }