public static IConfigurationBuilder AddCPlatformFile(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 (File.Exists(path))
     {
         if (provider == null && Path.IsPathRooted(path))
         {
             provider = new PhysicalFileProvider(Path.GetDirectoryName(path));
             path     = Path.GetFileName(path);
         }
         var source = new CPlatformConfigurationSource
         {
             FileProvider   = provider,
             Path           = path,
             Optional       = optional,
             ReloadOnChange = reloadOnChange
         };
         builder.Add(source);
         AppConfig.Configuration = builder.Build();
         AppConfig.ServerOptions = AppConfig.Configuration.Get <SurgingServerOptions>();
         var section = AppConfig.Configuration.GetSection("Surging");
         if (section.Exists())
         {
             AppConfig.ServerOptions = AppConfig.Configuration.GetSection("Surging").Get <SurgingServerOptions>();
         }
     }
     return(builder);
 }
        public static IConfigurationBuilder AddCacheFile(this IConfigurationBuilder builder, IFileProvider provider, string path, bool optional, bool reloadOnChange)
        {
            Check.NotNull(builder, "builder");
            Check.CheckCondition(() => string.IsNullOrEmpty(path), "path");
            if (provider == null && Path.IsPathRooted(path))
            {
                provider = new PhysicalFileProvider(Path.GetDirectoryName(path));
                path     = Path.GetFileName(path);
            }
            var source = new CPlatformConfigurationSource
            {
                FileProvider   = provider,
                Path           = path,
                Optional       = optional,
                ReloadOnChange = reloadOnChange
            };

            builder.Add(source);
            AppConfig.Configuration = builder.Build();
            return(builder);
        }
Exemplo n.º 3
0
 public CPlatformConfigurationProvider(CPlatformConfigurationSource source) : base(source)
 {
 }