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


C# ConfigurationBuilder.AddJsonFile方法代码示例

本文整理汇总了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);
            }
        }
开发者ID:rbarbe,项目名称:HadoukenApi,代码行数:29,代码来源:Functional.cs

示例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();
 }
开发者ID:mequanta,项目名称:Janitor-old,代码行数:8,代码来源:Startup.cs

示例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();
 }
开发者ID:Yanal-Yves,项目名称:ConsoleApp2,代码行数:8,代码来源:Startup.cs

示例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();
 }
开发者ID:Insvald,项目名称:Taygeta,代码行数:9,代码来源:Startup.cs

示例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();
        }
开发者ID:trungdd2811,项目名称:MongoMVC6,代码行数:15,代码来源:Startup.Configurations.cs

示例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();
        }
开发者ID:OsirisTerje,项目名称:musicstore-api-aspnet5,代码行数:15,代码来源:Startup.cs

示例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
        }
开发者ID:Tinkerc,项目名称:cloudscribe,代码行数:31,代码来源:Startup.cs

示例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();
 }
开发者ID:binarymash,项目名称:ReleaseManager2,代码行数:7,代码来源:Startup.cs

示例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);
        }
开发者ID:rpowers3,项目名称:TheBlackMarket,代码行数:60,代码来源:Startup.cs

示例10: DriverFixture

 public DriverFixture()
 {
     driver = new FirefoxDriver();
     //driver = new ChromeDriver();
     var configuration = new ConfigurationBuilder();
     configuration.AddJsonFile("config.json");
     config = configuration.Build(); 
 }
开发者ID:xebia,项目名称:xta-introduction-webdriver-dotnet,代码行数:8,代码来源:SharedDriver.cs

示例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();
 }
开发者ID:ridercz,项目名称:WifiGate,代码行数:8,代码来源:Startup.cs

示例12: GetConfiguration

        private IConfigurationRoot GetConfiguration()
        {
            var builder = new ConfigurationBuilder();
            var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config.json");

            builder.AddJsonFile(path);

            return builder.Build();
        }
开发者ID:stephenpope,项目名称:presentation-source,代码行数:9,代码来源:Startup.cs

示例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();
        }
开发者ID:gongdo,项目名称:orientdb-http-dnx,代码行数:18,代码来源:OrientDbFixture.cs

示例14: 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

示例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();
        }
开发者ID:blink2linkme,项目名称:Platformus,代码行数:10,代码来源:Configuration.cs


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