当前位置: 首页>>代码示例>>C#>>正文


C# ConfigurationBuilder.AddEnvironmentVariables方法代码示例

本文整理汇总了C#中Microsoft.Framework.Configuration.ConfigurationBuilder.AddEnvironmentVariables方法的典型用法代码示例。如果您正苦于以下问题:C# ConfigurationBuilder.AddEnvironmentVariables方法的具体用法?C# ConfigurationBuilder.AddEnvironmentVariables怎么用?C# ConfigurationBuilder.AddEnvironmentVariables使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Framework.Configuration.ConfigurationBuilder的用法示例。


在下文中一共展示了ConfigurationBuilder.AddEnvironmentVariables方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Startup

        public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
        {
            var builder = new ConfigurationBuilder(appEnv.ApplicationBasePath).AddJsonFile("config.json");

            builder.AddEnvironmentVariables();
            Configuration = builder.Build();
        }
开发者ID:psilon2000,项目名称:LUV,代码行数:7,代码来源:Startup.cs

示例2: Startup

 public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
 {
     var configurationBuilder = new ConfigurationBuilder(appEnv.ApplicationBasePath);
     configurationBuilder.AddEnvironmentVariables("BinaryMash.ReleaseManager:");
     configurationBuilder.AddJsonFile("Config.json");
     _configuration = configurationBuilder.Build();
 }
开发者ID:binarymash,项目名称:ReleaseManager2,代码行数:7,代码来源:Startup.cs

示例3: Main

        public void Main(string[] args)
        {
            // Allow the location of the ini file to be specified via a --config command line arg
            var tempBuilder = new ConfigurationBuilder().AddCommandLine(args);
            var tempConfig = tempBuilder.Build();
            var configFilePath = tempConfig[ConfigFileKey] ?? HostingIniFile;

            var appBasePath = _serviceProvider.GetRequiredService<IApplicationEnvironment>().ApplicationBasePath;
            var builder = new ConfigurationBuilder(appBasePath);
            builder.AddIniFile(configFilePath, optional: true);
            builder.AddEnvironmentVariables();
            builder.AddCommandLine(args);
            var config = builder.Build();

            var host = new WebHostBuilder(_serviceProvider, config).Build();
            using (host.Start())
            {
                Console.WriteLine("Started");
                var appShutdownService = host.ApplicationServices.GetRequiredService<IApplicationShutdown>();
                Console.CancelKeyPress += (sender, eventArgs) =>
                {
                    appShutdownService.RequestShutdown();
                    // Don't terminate the process immediately, wait for the Main thread to exit gracefully.
                    eventArgs.Cancel = true;
                };
                appShutdownService.ShutdownRequested.WaitHandle.WaitOne();
            }
        }
开发者ID:humblelistener,项目名称:Hosting,代码行数:28,代码来源:Program.cs

示例4: Startup

        public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
        {
            // Setup configuration sources.
            var builder = new ConfigurationBuilder()
                .SetBasePath(appEnv.ApplicationBasePath)
                .AddJsonFile("appsettings.json")
                .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);

            //appEnv.
            //env.EnvironmentName = "Development";

            if (env.IsEnvironment("Development"))
            {
                // This reads the configuration keys from the secret store.
                // For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709
                builder.AddUserSecrets();
            }

            // this file name is ignored by gitignore
            // so you can create it and use on your local dev machine
            // remember last config source added wins if it has the same settings
            builder.AddJsonFile("appsettings.local.overrides.json", optional: true);

            // most common use of environment variables would be in azure hosting
            // since it is added last anything in env vars would trump the same setting in previous config sources
            // so no risk of messing up settings if deploying a new version to azure
            builder.AddEnvironmentVariables();
            Configuration = builder.Build();

            //env.MapPath
        }
开发者ID:Tinkerc,项目名称:cloudscribe,代码行数:31,代码来源:Startup.cs

示例5: Startup

 public Startup(IApplicationEnvironment appEnv)
 {
     var configBuilder = new ConfigurationBuilder(appEnv.ApplicationBasePath);
     configBuilder.AddUserSecrets();
     configBuilder.AddEnvironmentVariables();
     _configuration = configBuilder.Build();
 }
开发者ID:glennc,项目名称:GHUtils,代码行数:7,代码来源:Startup.cs

示例6: Startup

        public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
        {
            // Setup configuration sources.

            var builder = new ConfigurationBuilder(appEnv.ApplicationBasePath)
                .AddJsonFile("config.json")
                .AddJsonFile($"config.{env.EnvironmentName}.json", optional: true);

            if (env.IsDevelopment())
            {
                // This reads the configuration keys from the secret store.
                // For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709
                builder.AddUserSecrets();

                // todo: use Configuration with config.json instead of hardcoded URLs
                AppSettings["WeatherApiDomain"] = "http://localhost:60583";
            }
            else
            {
                AppSettings["WeatherApiDomain"] = "http://nws-wapi-staging.azurewebsites.net:80";
            }

            builder.AddEnvironmentVariables();
            Configuration = builder.Build();
        }
开发者ID:johnsoaa,项目名称:weather-ui,代码行数:25,代码来源:Startup.cs

示例7: Startup

        public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
        {
            Log.Logger = new LoggerConfiguration()
                .MinimumLevel.Debug()
                .Enrich.WithMachineName()
                .Enrich.FromLogContext()
                .WriteTo.Console()
                .WriteTo.Seq("http://localhost:5341")
                .CreateLogger();

            Log.Information("Starting up");

            Metrics.Collector = new CollectorConfiguration()
                .Batch.AtInterval(TimeSpan.FromSeconds(5))
                .Tag.With("host", Environment.GetEnvironmentVariable("COMPUTERNAME"))
                .WriteTo.InfluxDB("http://192.168.99.100:8086", "data")
                .CreateCollector();

            var builder = new ConfigurationBuilder(appEnv.ApplicationBasePath)
                .AddJsonFile("config.json")
                .AddJsonFile($"config.{env.EnvironmentName}.json", optional: true);

            builder.AddEnvironmentVariables();
            Configuration = builder.Build();
        }
开发者ID:nblumhardt,项目名称:Bagels,代码行数:25,代码来源:Startup.cs

示例8: Startup

 public Startup(IHostingEnvironment env)
 {
     var configurationBuilder = new ConfigurationBuilder();
     configurationBuilder.AddJsonFile("config.json");
     configurationBuilder.AddJsonFile($"config.{env.EnvironmentName}.json", optional: true);
     configurationBuilder.AddEnvironmentVariables();
     this.Configuration = configurationBuilder.Build();
 }
开发者ID:Yanal-Yves,项目名称:ConsoleApp2,代码行数:8,代码来源:Startup.cs

示例9: ConfigureApplicationContainer

 protected override void ConfigureApplicationContainer(TinyIoCContainer container)
 {
     base.ConfigureApplicationContainer(container);
     var builder = new ConfigurationBuilder().AddJsonFile("config.json");
     builder.AddEnvironmentVariables();
     var configuration = builder.Build();
     container.Register<IConfiguration>(configuration);
 }
开发者ID:asizikov,项目名称:github-status,代码行数:8,代码来源:Bootrapper.cs

示例10: Startup

        public Startup(IHostingEnvironment env)
        {
            var configBuilder = new ConfigurationBuilder(env.WebRootPath);

            configBuilder.AddJsonFile("config.json");
            configBuilder.AddEnvironmentVariables();

            Configuration = configBuilder.Build();
        }
开发者ID:hitesh97,项目名称:BMUK_Angular_Polymer,代码行数:9,代码来源:Startup.cs

示例11: Startup

 public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
 {
     var builder = new ConfigurationBuilder(appEnv.ApplicationBasePath);
     builder.AddJsonFile("config.json");
     builder.AddJsonFile($"config.{env.EnvironmentName}.json", optional: true);
     builder.AddUserSecrets();
     builder.AddEnvironmentVariables();
     Configuration = builder.Build();
 }
开发者ID:mequanta,项目名称:Janitor-old,代码行数:9,代码来源:Startup.cs

示例12: Startup

        public Startup(IApplicationEnvironment env, IRuntimeEnvironment runtimeEnvironment)
        {
            // Setup configuration sources.
            var builder = new ConfigurationBuilder(env.ApplicationBasePath)
                .AddJsonFile("config.json");

            builder.AddEnvironmentVariables();
            Configuration = builder.Build();
        }
开发者ID:salerth,项目名称:aspnet5test,代码行数:9,代码来源:Startup.cs

示例13: Startup

 public Startup([NotNull] IHostingEnvironment env, [NotNull] IApplicationEnvironment appEnv)
 {
     // Setup configuration sources.
     ConfigurationBuilder builder = new ConfigurationBuilder(appEnv.ApplicationBasePath);
     builder.AddJsonFile("config.json");
     builder.AddJsonFile($"config.{env.EnvironmentName}.json", optional: true);
     builder.AddEnvironmentVariables();
     Configuration = builder.Build();
 }
开发者ID:Insvald,项目名称:Taygeta,代码行数:9,代码来源:Startup.cs

示例14: Configuration

        public Configuration(IApplicationEnvironment applicationEnvironment, IStorage storage)
        {
            ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();

              configurationBuilder.SetBasePath(applicationEnvironment.ApplicationBasePath);
              configurationBuilder.AddJsonFile("config.json");
              configurationBuilder.AddEnvironmentVariables();
              //configurationBuilder.AddStorage(storage);
              this.configuration = configurationBuilder.Build();
        }
开发者ID:blink2linkme,项目名称:Platformus,代码行数:10,代码来源:Configuration.cs

示例15: Startup

        public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
        {
            // Setup configuration sources.

            var builder = new ConfigurationBuilder()
                .SetBasePath(appEnv.ApplicationBasePath)
                .AddJsonFile("../OmniConf.Web/appsettings.json")
                .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);
            builder.AddEnvironmentVariables();
            Configuration = builder.Build();
        }
开发者ID:jaredfaris,项目名称:OmniConf,代码行数:11,代码来源:Startup.cs


注:本文中的Microsoft.Framework.Configuration.ConfigurationBuilder.AddEnvironmentVariables方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。