本文整理汇总了C#中Microsoft.Framework.Configuration.ConfigurationBuilder.AddJsonFile方法的典型用法代码示例。如果您正苦于以下问题:C# ConfigurationBuilder.AddJsonFile方法的具体用法?C# ConfigurationBuilder.AddJsonFile怎么用?C# ConfigurationBuilder.AddJsonFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Framework.Configuration.ConfigurationBuilder
的用法示例。
在下文中一共展示了ConfigurationBuilder.AddJsonFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Functional
public Functional()
{
var appEnv = CallContextServiceLocator.Locator.ServiceProvider.GetService(typeof(IApplicationEnvironment)) as IApplicationEnvironment;
Debug.Assert(appEnv != null, "appEnv != null");
var builder = new ConfigurationBuilder(appEnv.ApplicationBasePath);
builder.AddJsonFile("config.json");
builder.AddJsonFile("config.private.json", true);
var configuration = builder.Build();
var uri = new Uri(configuration["ServerCredentialUri"]);
var username = configuration["ServerCredentialUsername"];
var password = configuration["ServerCredentialPassword"];
_serverCredential = new ServerCredential(uri, username, password);
_freeMusicTorrentFile =
new HttpClient().GetByteArrayAsync(
new Uri("http://bt.etree.org/download.php/582271/hottuna2015-09-11.flac16.torrent")).Result;
_freeMusicTorrentHash = "9ecc7229ff971d27552dd399509e188847dbbbf1";
// Make sure there is no torrents before executing the tests
var api = new Api(_serverCredential);
var torrents = api.GetTorrents().Result;
if (torrents.Any())
{
var result = api.Perform(Action.Removedata, torrents.Select(t => t.InfoHash)).Result;
Assert.True(result);
}
}
示例2: Startup
public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
{
var builder = new ConfigurationBuilder(appEnv.ApplicationBasePath);
builder.AddJsonFile("config.json",optional: true);
builder.AddJsonFile($"config.{env.EnvironmentName}.json", optional: true);
builder.AddEnvironmentVariables();
Configuration = builder.Build();
}
示例3: 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();
}
示例4: 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();
}
示例5: ConfigureConfiguration
private static IConfiguration ConfigureConfiguration(
IApplicationEnvironment applicationEnvironment,
IHostingEnvironment hostingEnvironment)
{
ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(
applicationEnvironment.ApplicationBasePath);
// Add configuration from the config.json file.
configurationBuilder.AddJsonFile("config.json");
configurationBuilder.AddJsonFile($"config.{hostingEnvironment.EnvironmentName}.json", optional: true);
configurationBuilder.AddEnvironmentVariables();
return configurationBuilder.Build();
}
示例6: 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();
}
示例7: 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
}
示例8: Startup
public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
{
var configurationBuilder = new ConfigurationBuilder(appEnv.ApplicationBasePath);
configurationBuilder.AddEnvironmentVariables("BinaryMash.ReleaseManager:");
configurationBuilder.AddJsonFile("Config.json");
_configuration = configurationBuilder.Build();
}
示例9: Configure
public void Configure(IApplicationBuilder app)
{
ServiceProvider = app.ApplicationServices;
var applicationEnvironment = app.ApplicationServices.GetRequiredService<IApplicationEnvironment>();
var configurationFile = Path.Combine(applicationEnvironment.ApplicationBasePath, applicationEnvironment.ApplicationName) + ".json";
var configurationBuilder = new ConfigurationBuilder();
configurationBuilder.AddJsonFile(configurationFile);
Configuration = configurationBuilder.Build();
ConfigureLogging(app);
// Add site logging.
app.Use(async (request, next) => {
var accessLine = "<Unknown>";
try {
var remoteAddress = "";
var connectionFeature = request.GetFeature<IHttpConnectionFeature>();
if (connectionFeature != null) {
remoteAddress = connectionFeature.RemoteIpAddress.ToString();
}
if (string.IsNullOrWhiteSpace(remoteAddress)) {
remoteAddress = request.Request.Headers["HTTP_X_FORWARDED_FOR"];
}
if (string.IsNullOrWhiteSpace(remoteAddress)) {
remoteAddress = request.Request.Headers["REMOTE_ADDR"];
}
accessLine = string.Format(
"{0} {1} {2} {3}{4}{5}",
remoteAddress,
request.Request.Method,
request.Request.Protocol,
request.Request.Path,
request.Request.QueryString.HasValue ? "?" : "",
request.Request.QueryString);
var isHtml = Path.GetExtension(request.Request.Path).Equals(".html");
if (isHtml) {
HtmlAccessLog.LogInformation(accessLine);
}
AccessLog.LogInformation(accessLine);
await next();
} catch (Exception e) {
var message = string.Format("Exception processing request {0}", accessLine);
ApplicationLog.LogError(message, e);
}
});
ConfigureFileServer(app);
}
示例10: DriverFixture
public DriverFixture()
{
driver = new FirefoxDriver();
//driver = new ChromeDriver();
var configuration = new ConfigurationBuilder();
configuration.AddJsonFile("config.json");
config = configuration.Build();
}
示例11: Startup
public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
{
// Setup configuration sources
var builder = new ConfigurationBuilder(appEnv.ApplicationBasePath);
builder.AddJsonFile("config.json");
builder.AddEnvironmentVariables();
this.Configuration = builder.Build();
}
示例12: GetConfiguration
private IConfigurationRoot GetConfiguration()
{
var builder = new ConfigurationBuilder();
var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config.json");
builder.AddJsonFile(path);
return builder.Build();
}
示例13: OrientDbFixture
public OrientDbFixture()
{
client = GetClient();
var builder = new ConfigurationBuilder(Directory.GetCurrentDirectory());
builder.AddJsonFile("config.json", true);
builder.AddJsonFile("config.local.json", true);
var subConfig = builder.Build().GetConfigurationSection(LocalConfigurationKey);
Assert.NotNull(subConfig);
config.ServerPath = subConfig.Get("ServerPath");
config.RootPassword = subConfig.Get("RootPassword");
config.Database = subConfig.Get("Database");
Assert.NotNull(config.ServerPath);
Assert.NotNull(config.RootPassword);
Assert.NotNull(config.Database);
EnsureServerRunning();
EnsureTestDatabase();
}
示例14: Startup
public Startup(IHostingEnvironment env)
{
var configBuilder = new ConfigurationBuilder(env.WebRootPath);
configBuilder.AddJsonFile("config.json");
configBuilder.AddEnvironmentVariables();
Configuration = configBuilder.Build();
}
示例15: 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();
}