public FileSnapshotStorageConnector(FileConfigRespositoryBuilderOptions options)
 {
     folderPath = $"{options.ConfigStorePath}/Snapshot";
 }
 public FileConfigArchive(FileConfigRespositoryBuilderOptions options)
 {
     folderPath = $"{options.ConfigStorePath}/Archive";
 }
        /// <summary>
        /// Uses FileConfigRepository as IConfigRepository
        /// </summary>
        /// <param name="builder">ConfigServerBuilder to add FileConfigRepository to</param>
        /// <param name="options">Options for FileConfigRepository</param>
        /// <returns>ConfigServer builder for further configuration</returns>
        public static ConfigServerBuilder UseFileConfigProvider(this ConfigServerBuilder builder, FileConfigRespositoryBuilderOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }
            if (string.IsNullOrWhiteSpace(options.ConfigStorePath))
            {
                throw new ArgumentException($"{nameof(FileConfigRespositoryBuilderOptions.ConfigStorePath)} cannot be null or whitespace", nameof(options));
            }
            builder.ServiceCollection.AddSingleton(options);
            builder.ServiceCollection.AddTransient <IConfigRepository, TextStorageConfigurationRepository>();
            builder.ServiceCollection.AddTransient <IConfigClientRepository, TextStorageConfigurationClientRepository>();
            builder.ServiceCollection.AddTransient <IConfigProvider, TextStorageConfigurationRepository>();
            builder.ServiceCollection.AddTransient <IStorageConnector, FileStorageConnector>();
            builder.ServiceCollection.AddTransient <IConfigArchive, FileConfigArchive>();
            builder.ServiceCollection.AddTransient <IConfigurationSnapshotRepository, TextStorageSnapshotRepository>();
            builder.ServiceCollection.AddTransient <ISnapshotStorageConnector, FileSnapshotStorageConnector>();


            return(builder);
        }
 public FileStorageConnector(FileConfigRespositoryBuilderOptions options)
 {
     folderPath = options.ConfigStorePath;
 }
        /// <summary>
        /// Uses FileConfigRepository as IConfigRepository
        /// </summary>
        /// <param name="builder">ConfigServerBuilder to add FileConfigRepository to</param>
        /// <param name="options">Options for FileConfigRepository</param>
        /// <returns>ConfigServer builder for further configuration</returns>
        public static ConfigServerBuilder UseFileConfigProvider(this ConfigServerBuilder builder, FileConfigRespositoryBuilderOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }
            if (string.IsNullOrWhiteSpace(options.ConfigStorePath))
            {
                throw new ArgumentException($"{nameof(FileConfigRespositoryBuilderOptions.ConfigStorePath)} cannot be null or whitespace", nameof(options));
            }
            options.JsonSerializerSettings = options.JsonSerializerSettings ?? new JsonSerializerSettings();
            builder.ServiceCollection.AddMemoryCache();
            builder.ServiceCollection.Add(ServiceDescriptor.Singleton(options));
            builder.ServiceCollection.Add(ServiceDescriptor.Singleton <ITextStorageSetting>(options));
            builder.ServiceCollection.Add(ServiceDescriptor.Transient <IConfigRepository, TextStorageConfigurationRepository>());
            builder.ServiceCollection.Add(ServiceDescriptor.Transient <IConfigProvider, TextStorageConfigurationRepository>());
            builder.ServiceCollection.Add(ServiceDescriptor.Transient <IStorageConnector, FileStorageConnector>());

            return(builder);
        }