/// <summary>
        /// Adds ConfigSet to config model registry
        /// </summary>
        /// <typeparam name="TConfigSet">Type of config set to be added to registry</typeparam>
        /// <param name="source">The IServiceCollection to add config set to</param>
        /// <returns>ConfigServer builder for further configuration</returns>
        public static ConfigServerBuilder UseConfigSet <TConfigSet>(this ConfigServerBuilder source) where TConfigSet : ConfigurationSet <TConfigSet>, new()
        {
            var configSet  = new TConfigSet();
            var definition = configSet.BuildConfigurationSetModel();

            source.ConfigurationSetCollection.AddConfigurationSet(definition);
            return(source);
        }
        /// <summary>
        /// Adds Local ConfigServer client to specified ServiceCollection
        /// </summary>
        /// <param name="source">The IServiceCollection to add local ConfigServer client to</param>
        /// <param name="applicationId">Identifier for application requesting the configuration</param>
        /// <returns>ConfigServer client builder for further configuration of client</returns>
        public static ConfigServerClientBuilder UseLocalConfigServerClient(this ConfigServerBuilder source, string applicationId)
        {
            var configurationCollection = new ConfigurationRegistry();
            var builder = new ConfigServerClientBuilder(source.ServiceCollection, configurationCollection);

            source.ServiceCollection.Add(ServiceDescriptor.Transient <IConfigServer>(r => new LocalConfigServerClient(r.GetService <IConfigProvider>(), applicationId)));
            return(builder);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Adds Local ConfigServer client to specified ServiceCollection
        /// </summary>
        /// <param name="source">The ConfigServerBuilder to add local ConfigServer client to</param>
        /// <param name="configServeruri">Identifier for application requesting the configuration</param>
        /// <returns>ConfigServer client builder for further configuration of client</returns>
        public static ConfigServerClientBuilder UseLocalConfigServerClient(this ConfigServerBuilder source, Uri configServeruri)
        {
            var builder = new ConfigServerClientBuilder(source.ServiceCollection);
            var option  = new LocalServerClientOptions(configServeruri);

            builder.AddSingleton(option);
            builder.AddTransient <IConfigServer, LocalConfigServerClient>();
            builder.AddTransient <IResourceServer, LocalResourceServerClient>();
            return(builder);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Uses Distributed Caching strategy
 /// </summary>
 /// <param name="source">The ConfigServerBuildern to add the strategy to</param>
 /// <returns>ConfigServer builder for further configuration</returns>
 public static ConfigServerBuilder UseDistributedCachingStrategy(this ConfigServerBuilder source) => source.UseCachingStrategy <DistributedCachingStrategy>();
Ejemplo n.º 5
0
 /// <summary>
 /// Uses InMemory Caching strategy
 /// </summary>
 /// <param name="source">The ConfigServerBuildern to add the strategy to</param>
 /// <returns>ConfigServer builder for further configuration</returns>
 public static ConfigServerBuilder UseInMemoryCachingStrategy(this ConfigServerBuilder source) => source.UseCachingStrategy <MemoryCachingStrategy>();
Ejemplo n.º 6
0
 /// <summary>
 /// Adds CachingStrategy
 /// </summary>
 /// <typeparam name="TStrategy">Strategy to use</typeparam>
 /// <param name="source">The ConfigServerBuildern to add the strategy to</param>
 /// <returns>ConfigServer builder for further configuration</returns>
 public static ConfigServerBuilder UseCachingStrategy <TStrategy>(this ConfigServerBuilder source) where TStrategy : class, ICachingStrategy
 {
     source.ServiceCollection.AddTransient <ICachingStrategy, TStrategy>();
     return(source);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Sets version of configuration service
 /// </summary>
 /// <param name="source">The ConfigServerBuilder to set the version for</param>
 /// <param name="version">Version of the configuration service. Helps to manage changes in the configuration sets</param>
 /// <returns>ConfigServer builder for further configuration</returns>
 public static ConfigServerBuilder WithVersion(this ConfigServerBuilder source, Version version)
 {
     source.SetVersion(version);
     return(source);
 }