Exemplo n.º 1
0
        public IActionResult List(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "providers")] HttpRequest req,
            ILogger log)
        {
            if (!req.IsValidUser())
            {
                return(new UnauthorizedResult());
            }

            log.LogInformation("Listing loaded Providers.");

            return(new OkObjectResult(LoadedProviders.Select(p => GetViewModel(p))));
        }
        public async Task <IEnumerable <ProviderResourceSuggestion> > EnumerateProviders(AccessTokenCredential credential)
        {
            var providers = (await Task.WhenAll(
                                 LoadedProviders.Select(p => GetProviderInstanceDefault(p.ProviderTypeName))
                                 .OfType <ICanEnumerateResourceCandidates>()
                                 .Select(p => EnumerateProviders(credential, p))))
                            .Where(c => c != null)
                            .SelectMany(c => c);

            foreach (var provider in providers.Where(p => p.AddressableNames.Any()))
            {
                foreach (var name in provider.AddressableNames)
                {
                    var refs = providers.Where(p => p.ResourceValues.Any(r => r.Contains(name)));
                    provider.ResourcesAddressingThis.AddRange(refs);
                }
            }

            return(providers);
        }