Exemplo n.º 1
0
        public IHttpMessageSigningVerificationBuilder UseClientStore(Func <IServiceProvider, IClientStore> clientStoreFactory)
        {
            if (clientStoreFactory == null)
            {
                throw new ArgumentNullException(nameof(clientStoreFactory));
            }

            Services.AddSingleton(provider => {
                _clientStore = clientStoreFactory(provider);
                foreach (var clientFactory in ClientFactories)
                {
                    var client = clientFactory?.Invoke(provider);
                    if (client != null)
                    {
                        _clientStore
                        .Register(client)
                        .GetAwaiter()
                        .GetResult();
                    }
                }
                return(_clientStore);
            });

            return(this);
        }
        public async Task Register(Client client)
        {
            await _decorated.Register(client).ConfigureAwait(continueOnCapturedContext: false);

            if (_expiration > TimeSpan.Zero)
            {
                var cacheKey = $"CacheEntry_Client_{client.Id}";
                var options  = BuildEntryOptions();
                _cache.Set(cacheKey, client, options);
            }
        }
 public async Task Register(Client client)
 {
     using (await _lock.WriterLockAsync()) {
         await _decorated.Register(client);
     }
 }