/// <summary>
        /// Adds the consul file.
        /// </summary>
        /// <param name="builder">The builder.</param>
        /// <param name="provider">The provider.</param>
        /// <param name="path">The path.</param>
        /// <param name="optional">if set to <c>true</c> [optional].</param>
        /// <param name="reloadOnChange">if set to <c>true</c> [reload on change].</param>
        /// <returns>IConfigurationBuilder.</returns>
        public static IConfigurationBuilder AddConsulFile(this IConfigurationBuilder builder, IFileProvider provider,
                                                          string path, bool optional, bool reloadOnChange)
        {
            Check.NotNull(builder, "builder");
            Check.CheckCondition(() => string.IsNullOrEmpty(path), "path");
            path = EnvironmentHelper.GetEnvironmentVariable(path);
            if (provider == null && Path.IsPathRooted(path))
            {
                provider = new PhysicalFileProvider(Path.GetDirectoryName(path));
                path     = Path.GetFileName(path);
            }

            var source = new ConsulConfigurationSource
            {
                FileProvider   = provider,
                Path           = path,
                Optional       = optional,
                ReloadOnChange = reloadOnChange
            };

            builder.Add(source);
            AppConfig.Configuration = builder.Build();
            return(builder);
        }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ConsulConfigurationProvider" /> class.
 /// </summary>
 /// <param name="source">The source.</param>
 public ConsulConfigurationProvider(ConsulConfigurationSource source) : base(source)
 {
 }