public static IConfigurationBuilder AddCPlatformFile(this IConfigurationBuilder builder, IFileProvider provider, string path, string basePath, 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);
                if (!string.IsNullOrEmpty(basePath))
                {
                    builder.SetBasePath(basePath);
                }
                AppConfig.Configuration = builder.Build();

                var surgingSection = AppConfig.Configuration.GetSection("Surging");
                if (surgingSection.Exists())
                {
                    AppConfig.ServerOptions = surgingSection.Get <SurgingServerOptions>();
                }
                var actionMapSecetion = AppConfig.Configuration.GetSection("Swagger:Options:MapRoutePaths");
                if (actionMapSecetion.Exists())
                {
                    AppConfig.MapRoutePathOptions = actionMapSecetion.Get <IEnumerable <MapRoutePathOption> >();
                }
            }
            return(builder);
        }
Beispiel #2
0
 public CPlatformConfigurationProvider(CPlatformConfigurationSource source) : base(source)
 {
 }