Exemplo n.º 1
0
 public ConfigServerClient(IHttpClientWrapper client, IClientCachingStrategy cache, IClientIdProvider clientIdProvider, IConfigurationRegistry collection, ConfigServerClientOptions options)
 {
     this.client           = client;
     this.collection       = collection;
     this.options          = options;
     this.cache            = cache;
     this.clientIdProvider = clientIdProvider;
 }
Exemplo n.º 2
0
 public ConfigServerClient(IHttpClientWrapper client, IMemoryCache memorycache, ConfigurationRegistry collection, ConfigServerClientOptions options)
 {
     this.client     = client;
     this.collection = collection;
     this.options    = options;
     if (memorycache == null && !options.CacheOptions.IsDisabled)
     {
         throw new ArgumentNullException(nameof(memorycache), "Caching is enabled, but IMemoryCache is not registered in service collection. Try adding \"services.AddMemoryCache()\" to startup file");
     }
     this.cache = memorycache;
 }
Exemplo n.º 3
0
 public MemoryClientCachingStrategy(IMemoryCache memorycache, ConfigServerClientOptions options)
 {
     this.memorycache = memorycache;
     this.options     = options;
 }
Exemplo n.º 4
0
 public ResourceServerClient(IHttpClientWrapper client, ConfigServerClientOptions options, IClientIdProvider clientIdProvider)
 {
     this.client           = client;
     this.options          = options;
     this.clientIdProvider = clientIdProvider;
 }
Exemplo n.º 5
0
        /// <summary>
        /// Adds ConfigServer client to specified ServiceCollection
        /// </summary>
        /// <param name="source">The IServiceCollection to add ConfigServer client to</param>
        /// <param name="options">Options for ConfigServer client</param>
        /// <returns>ConfigServer client builder for further configuration</returns>
        public static ConfigServerClientBuilder AddConfigServerClient(this IServiceCollection source, ConfigServerClientOptions options)
        {
            var configurationCollection = new ConfigurationRegistry();
            var builder = new ConfigServerClientBuilder(source, configurationCollection);

            source.Add(ServiceDescriptor.Transient <IHttpClientWrapper>(r => new HttpClientWrapper(options.Authenticator)));
            source.Add(ServiceDescriptor.Transient <IConfigServerClient>(r => new ConfigServerClient(r.GetService <IHttpClientWrapper>(), r.GetService <IMemoryCache>(), r.GetService <ConfigurationRegistry>(), options)));
            return(builder);
        }
Exemplo n.º 6
0
 private static ConfigServerClientBuilder SetUpBuilder(ConfigServerClientBuilder builder, ConfigServerClientOptions options)
 {
     builder.AddSingleton(options);
     builder.AddSingleton <IHttpClientWrapper>(new HttpClientWrapper(options.Authenticator));
     builder.AddTransient <IConfigServer, ConfigServerClient>();
     builder.AddTransient <IResourceServer, ResourceServerClient>();
     if (options.CacheOptions.IsDisabled)
     {
         builder.AddTransient <IClientCachingStrategy, NoCachingStrategy>();
     }
     else
     {
         builder.AddTransient <IClientCachingStrategy, MemoryClientCachingStrategy>();
     }
     return(builder);
 }
Exemplo n.º 7
0
 /// <summary>
 /// Adds ConfigServer client to specified ServiceCollection
 /// </summary>
 /// <param name="source">The IServiceCollection to add ConfigServer client to</param>
 /// <param name="options">Options for ConfigServer client</param>
 /// <returns>ConfigServer client builder for further configuration</returns>
 public static ConfigServerClientBuilder AddConfigServerClient(this IServiceCollectionWrapper source, ConfigServerClientOptions options)
 {
     return(SetUpBuilder(new ConfigServerClientBuilder(source), options));
 }