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