Пример #1
0
 /// <summary>
 /// Gets API resources by scope name.
 /// </summary>
 public virtual async Task <IEnumerable <IdentityServer4.Models.ApiResource> > FindApiResourcesByScopeNameAsync(IEnumerable <string> scopeNames)
 {
     return(await GetCacheItemsAsync <ApiResource, IdentityServer4.Models.ApiResource>(
                ApiResourceCache,
                scopeNames,
                async keys => await ApiResourceRepository.GetListByScopesAsync(keys, includeDetails: true),
                (models, cacheKeyPrefix) =>
     {
         return models
         .Select(model => model.Scopes.Select(scope => new KeyValuePair <string, IdentityServer4.Models.ApiResource>(AddCachePrefix(scope, cacheKeyPrefix), model)).ToList())
         .Where(scopes => scopes.Any()).Cast <IEnumerable <KeyValuePair <string, IdentityServer4.Models.ApiResource> > >().ToList();
     }, ApiResourceScopeNameCacheKeyPrefix));
 }
Пример #2
0
        public virtual async Task <IEnumerable <ApiResource> > FindApiResourcesByScopeAsync(IEnumerable <string> scopeNames)
        {
            var resources = await ApiResourceRepository.GetListByScopesAsync(scopeNames.ToArray(), includeDetails : true);

            return(resources.Select(x => ObjectMapper.Map <ApiResources.ApiResource, ApiResource>(x)));
        }