/// <summary>
        /// Adds a remote configuration source to <paramref name="builder"/>.
        /// </summary>
        /// <param name="builder">The <see cref="IConfigurationBuilder"/> to add to.</param>
        /// <param name="configurationUri">The remote uri to </param>
        /// <param name="optional">Whether the remote configuration source is optional.</param>
        /// <param name="events">Events that get add </param>
        /// <returns>The <see cref="IConfigurationBuilder"/>.</returns>
        public static IConfigurationBuilder AddRemoteSource(this IConfigurationBuilder builder, Uri configurationUri, bool optional, RemoteConfigurationEvents events)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

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

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

            var source = new RemoteConfigurationSource
            {
                ConfigurationUri = configurationUri,
                Events           = events,
                Optional         = optional,
            };

            return(builder.AddRemoteSource(source));
        }
Beispiel #2
0
 public RemoteConfigurationProvider(RemoteConfigurationSource source)
 {
     Check.NotNull(source, "source");
     if (!string.IsNullOrEmpty(source.ConfigurationKeyPrefix))
     {
         Check.CheckCondition(() => source.ConfigurationKeyPrefix.Trim().StartsWith(":"), CPlatformResource.InvalidStartCharacter, "source.ConfigurationKeyPrefix", ":");
         Check.CheckCondition(() => source.ConfigurationKeyPrefix.Trim().EndsWith(":"), CPlatformResource.InvalidEndCharacter, "source.ConfigurationKeyPrefix", ":");
     }
     Source      = source;
     Backchannel = new HttpClient(source.BackchannelHttpHandler ?? new HttpClientHandler());
     Backchannel.DefaultRequestHeaders.UserAgent.ParseAdd("获取CacheConfiugration信息");
     Backchannel.Timeout = source.BackchannelTimeout;
     Backchannel.MaxResponseContentBufferSize = 1024 * 1024 * 10;
     Parser = source.Parser ?? new JsonConfigurationParser();
 }
        public static IConfigurationBuilder AddRemoteSource(this IConfigurationBuilder builder, RemoteConfigurationSource source)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

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

            builder.Add(source);
            return(builder);
        }