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);
        }
Ejemplo 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('/'));
        }
Ejemplo n.º 3
0
 public static string GetSearchAutocompleteResourceUrl(this ServiceIndexResponse serviceIndex)
 {
     return(serviceIndex.GetResourceUrl(SearchAutocompleteService));
 }
Ejemplo n.º 4
0
 public static string GetSearchQueryResourceUrl(this ServiceIndexResponse serviceIndex)
 {
     return(serviceIndex.GetResourceUrl(SearchQueryService));
 }
Ejemplo n.º 5
0
 public static string GetCatalogResourceUrl(this ServiceIndexResponse serviceIndex)
 {
     return(serviceIndex.GetResourceUrl(Catalog));
 }
Ejemplo n.º 6
0
 public static string GetPackageMetadataResourceUrl(this ServiceIndexResponse serviceIndex)
 {
     return(serviceIndex.GetResourceUrl(RegistrationsBaseUrl));
 }
Ejemplo n.º 7
0
 public static string GetPackageContentResourceUrl(this ServiceIndexResponse serviceIndex)
 {
     return(serviceIndex.GetResourceUrl(PackageBaseAddress));
 }
Ejemplo n.º 8
0
 private UrlGeneratorClient(ServiceIndexResponse serviceIndex)
 {
     _serviceIndex = serviceIndex ?? throw new ArgumentNullException(nameof(serviceIndex));
 }