Exemple #1
0
        /// <summary>
        /// Adds a custom configuration publisher.
        /// </summary>
        /// <param name="builder">The <see cref="IConfigurationServiceBuilder"/> to add services to.</param>
        /// <param name="publisher">The custom implementation of <see cref="IPublisher"/>.</param>
        /// <returns>An <see cref="IConfigurationServiceBuilder"/> that can be used to further configure the
        /// ConfigurationService services.</returns>
        public static IConfigurationServiceBuilder AddPublisher(this IConfigurationServiceBuilder builder, IPublisher publisher)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            if (publisher == null)
            {
                throw new ArgumentNullException(nameof(publisher));
            }

            builder.Services.AddSingleton(publisher);

            return(builder);
        }
Exemple #2
0
        /// <summary>
        /// Adds Redis as the configuration publisher.
        /// </summary>
        /// <param name="builder">The <see cref="IConfigurationServiceBuilder"/> to add services to.</param>
        /// <param name="configuration">The string configuration for the Redis multiplexer.</param>
        /// <returns>An <see cref="IConfigurationServiceBuilder"/> that can be used to further configure the
        /// ConfigurationService services.</returns>
        public static IConfigurationServiceBuilder AddRedisPublisher(this IConfigurationServiceBuilder builder, string configuration)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            var options = ConfigurationOptions.Parse(configuration);

            builder.Services.AddSingleton(options);
            builder.Services.AddSingleton <IPublisher, RedisPublisher>();

            return(builder);
        }
Exemple #3
0
        /// <summary>
        /// Add file system as the storage provider backend.
        /// </summary>
        /// <param name="builder">The <see cref="IConfigurationServiceBuilder"/> to add services to.</param>
        /// <param name="configure">Configure file system provider options.</param>
        /// <returns>An <see cref="IConfigurationServiceBuilder"/> that can be used to further configure the
        /// ConfigurationService services.</returns>
        public static IConfigurationServiceBuilder AddFileSystemProvider(this IConfigurationServiceBuilder builder, Action <FileSystemProviderOptions> configure)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            if (configure == null)
            {
                throw new ArgumentNullException(nameof(configure));
            }

            var options = new FileSystemProviderOptions();

            configure(options);

            builder.Services.AddSingleton(options);
            builder.Services.AddSingleton <IProvider, FileSystemProvider>();

            return(builder);
        }
Exemple #4
0
        /// <summary>
        /// Adds NATS as the configuration publisher.
        /// </summary>
        /// <param name="builder">The <see cref="IConfigurationServiceBuilder"/> to add services to.</param>
        /// <param name="configure">Configure options for the NATS connection.</param>
        /// <returns>An <see cref="IConfigurationServiceBuilder"/> that can be used to further configure the
        /// ConfigurationService services.</returns>
        public static IConfigurationServiceBuilder AddNatsPublisher(this IConfigurationServiceBuilder builder, Action <Options> configure)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            if (configure == null)
            {
                throw new ArgumentNullException(nameof(configure));
            }

            var options = ConnectionFactory.GetDefaultOptions();

            configure(options);

            builder.Services.AddSingleton(options);
            builder.Services.AddSingleton <IPublisher, NatsPublisher>();

            return(builder);
        }
Exemple #5
0
        /// <summary>
        /// Adds Redis as the configuration publisher.
        /// </summary>
        /// <param name="builder">The <see cref="IConfigurationServiceBuilder"/> to add services to.</param>
        /// <param name="configure">Configure options for the Redis multiplexer.</param>
        /// <returns>An <see cref="IConfigurationServiceBuilder"/> that can be used to further configure the
        /// ConfigurationService services.</returns>
        public static IConfigurationServiceBuilder AddRedisPublisher(this IConfigurationServiceBuilder builder, Action <ConfigurationOptions> configure)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            if (configure == null)
            {
                throw new ArgumentNullException(nameof(configure));
            }

            var options = new ConfigurationOptions();

            configure(options);

            builder.Services.AddSingleton(options);
            builder.Services.AddSingleton <IPublisher, RedisPublisher>();

            return(builder);
        }