本文整理汇总了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();
}
示例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();
}
示例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();
}
}
示例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
}
示例5: Startup
public Startup(IApplicationEnvironment appEnv)
{
var configBuilder = new ConfigurationBuilder(appEnv.ApplicationBasePath);
configBuilder.AddUserSecrets();
configBuilder.AddEnvironmentVariables();
_configuration = configBuilder.Build();
}
示例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();
}
示例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();
}
示例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();
}
示例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);
}
示例10: Startup
public Startup(IHostingEnvironment env)
{
var configBuilder = new ConfigurationBuilder(env.WebRootPath);
configBuilder.AddJsonFile("config.json");
configBuilder.AddEnvironmentVariables();
Configuration = configBuilder.Build();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}