本文整理汇总了C#中Microsoft.Framework.Configuration.ConfigurationBuilder.AddUserSecrets方法的典型用法代码示例。如果您正苦于以下问题:C# ConfigurationBuilder.AddUserSecrets方法的具体用法?C# ConfigurationBuilder.AddUserSecrets怎么用?C# ConfigurationBuilder.AddUserSecrets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Framework.Configuration.ConfigurationBuilder
的用法示例。
在下文中一共展示了ConfigurationBuilder.AddUserSecrets方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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();
}
示例2: 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
}
示例3: Startup
public Startup(IApplicationEnvironment appEnv)
{
var configBuilder = new ConfigurationBuilder(appEnv.ApplicationBasePath);
configBuilder.AddUserSecrets();
configBuilder.AddEnvironmentVariables();
_configuration = configBuilder.Build();
}
示例4: 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();
}
示例5: Startup
public Startup(IApplicationEnvironment appEnv, IHostingEnvironment env)
{
var configBuilder = new ConfigurationBuilder(appEnv.ApplicationBasePath)
.AddJsonFile("config.json", optional: true);
if (env.IsDevelopment())
{
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")
.AddEnvironmentVariables();
if (env.IsDevelopment())
{
builder.AddUserSecrets();
}
Configuration = builder.Build();
}
示例7: 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);
// development via user-secret
if (env.IsDevelopment())
{
builder.AddUserSecrets();
}
builder.AddEnvironmentVariables();
Configuration = builder.Build();
}
示例8: Startup
public Startup(IHostingEnvironment env)
{
// Setup configuration sources.
var configuration = new ConfigurationBuilder()
.AddJsonFile("config.json")
.AddJsonFile($"config.{env.EnvironmentName}.json", optional: true);
if (env.IsEnvironment("Development"))
{
configuration.AddUserSecrets();
}
configuration.AddEnvironmentVariables();
Configuration = configuration.Build();
}
示例9: Startup
public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
{
// Setup configuration sources.
var builder = new ConfigurationBuilder(appEnv.ApplicationBasePath).AddJsonFile("config.json").AddJsonFile($"config.{env.EnvironmentName}.json", 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();
}
builder.AddEnvironmentVariables();
this.Configuration = builder.Build();
}
示例10: Startup
public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
{
var builder = new ConfigurationBuilder()
.SetBasePath(appEnv.ApplicationBasePath);
if (env.IsDevelopment())
{
builder.AddJsonFile("appsettings.json").AddJsonFile("privatesettings.json");
}
builder.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);
builder.AddUserSecrets();
builder.AddEnvironmentVariables();
this.Configuration = builder.Build();
}
示例11: Startup
public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
{
DbMapping.Init();
// Setup configuration sources.
var configuration = new ConfigurationBuilder(appEnv.ApplicationBasePath);
configuration.AddJsonFile("config.json");
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
configuration.AddUserSecrets();
}
configuration.AddEnvironmentVariables();
Configuration = configuration.Build();
}
示例12: Startup
public Startup(IHostingEnvironment env)
{
// Setup configuration sources.
var builder = new ConfigurationBuilder(env.MapPath(@"..\"))
.AddJsonFile("config.json", optional: true)
.AddJsonFile($"config.{env.EnvironmentName}.json", optional: true);
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();
builder.AddApplicationInsightsSettings(developerMode: true);
}
builder.AddEnvironmentVariables();
Configuration = builder.Build();
}
示例13: Startup
public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
{
// Setup configuration sources.
var builder = new ConfigurationBuilder(appEnv.ApplicationBasePath)
.AddJsonFile("config.json", true)
.AddJsonFile($"config.{env.EnvironmentName}.json", true);
builder.AddUserSecrets();
if (env.IsDevelopment())
{
// put ApplicationInsights in developer mode
builder.AddApplicationInsightsSettings(true);
}
builder.AddEnvironmentVariables();
Configuration = builder.Build();
}
示例14: Startup
public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
{
// Setup configuration sources.
var builder = new ConfigurationBuilder(appEnv.ApplicationBasePath)
.AddJsonFile("config.json")
.AddEnvironmentVariables()
.AddJsonFile($"config.{env.EnvironmentName}.json", optional: true);
if (env.IsDevelopment())
{
// This will push telemetry data through Application Insights pipeline faster, allowing you to view results immediately.
builder.AddApplicationInsightsSettings(developerMode: true);
// For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709
builder.AddUserSecrets();
}
builder.AddEnvironmentVariables();
Configuration = builder.Build();
}
示例15: 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();
}
builder.AddEnvironmentVariables();
Configuration = builder.Build();
Configuration["Data:DefaultConnection:ConnectionString"] = [email protected]"Data Source={appEnv.ApplicationBasePath}/<%= namespace %>.db";
}