コード例 #1
0
        /// <summary>
        /// Add Nacos Configuration
        /// </summary>
        /// <param name="builder">IConfigurationBuilder</param>
        /// <param name="configuration">Configuration binding nacos configuration source</param>
        /// <returns></returns>
        public static IConfigurationBuilder AddNacosConfiguration(
            this IConfigurationBuilder builder, IConfiguration configuration)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

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

            var source = new NacosConfigurationSource();

            configuration.Bind(source);

            return(builder.Add(source));
        }
コード例 #2
0
        /// <summary>
        /// Add Nacos Configuration
        /// </summary>
        /// <param name="builder">IConfigurationBuilder</param>
        /// <param name="action">setup NacosConfigurationSource</param>
        /// <returns>IConfigurationBuilder</returns>
        public static IConfigurationBuilder AddNacosConfiguration(
            this IConfigurationBuilder builder, Action <NacosConfigurationSource> action)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

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

            var source = new NacosConfigurationSource();

            action(source);

            source.NacosConfigurationParser ??= DefaultJsonConfigurationStringParser.Instance;

            return(builder.Add(source));
        }
コード例 #3
0
        /// <summary>
        /// Add Nacos Configuration
        /// </summary>
        /// <param name="builder">IConfigurationBuilder</param>
        /// <param name="configuration">Configuration binding nacos configuration source</param>
        /// <param name="parser">The parser.</param>
        /// <returns>IConfigurationBuilder</returns>
        public static IConfigurationBuilder AddNacosConfiguration(
            this IConfigurationBuilder builder,
            IConfiguration configuration,
            INacosConfigurationParser parser = null)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

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

            var source = new NacosConfigurationSource();

            configuration.Bind(source);
            source.NacosConfigurationParser = parser ?? DefaultJsonConfigurationStringParser.Instance;

            return(builder.Add(source));
        }