• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Configuration.ConfigurationBuilder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



ConfigurationBuilder类属于Microsoft.Framework.Configuration命名空间,在下文中一共展示了ConfigurationBuilder类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: UmbracoConfig

 public UmbracoConfig(IApplicationEnvironment appEnv)
 {
     var cfg = new ConfigurationBuilder()
         .SetBasePath(appEnv.ApplicationBasePath)
         .AddJsonFile("umbraco.json");
     _config = cfg.Build();
 }
开发者ID:ryanmcdonough,项目名称:Umbraco9,代码行数:7,代码来源:UmbracoConfig.cs


示例2: Startup

 public Startup(IHostingEnvironment environment)
 {
     Configuration = new ConfigurationBuilder(".")
         .AddJsonFile("config.json")
         .AddEnvironmentVariables()
         .Build();
 }
开发者ID:wmeints,项目名称:aspnet-demo,代码行数:7,代码来源:Startup.cs


示例3: Startup

 public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
 {
     var configuration =
         new ConfigurationBuilder(appEnv.ApplicationBasePath).AddJsonFile("config.json", false)
             .AddEnvironmentVariables();
     this.Configuration = configuration.Build();
 }
开发者ID:LukaszSzulc,项目名称:TGD.NET,代码行数:7,代码来源:Startup.cs


示例4: Startup

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


示例5: ActivityApiControllerTest

        public ActivityApiControllerTest()
        {
            if (_serviceProvider == null)
            {
                var services = new ServiceCollection();

                // Add Configuration to the Container
                var builder = new ConfigurationBuilder()
                    .SetBasePath(Directory.GetCurrentDirectory())
                    .AddEnvironmentVariables();
                IConfiguration configuration = builder.Build();
                services.AddSingleton(x => configuration);

                // Add EF (Full DB, not In-Memory)
                services.AddEntityFramework()
                    .AddInMemoryDatabase()
                    .AddDbContext<AllReadyContext>(options => options.UseInMemoryDatabase());

                // Setup hosting environment
                IHostingEnvironment hostingEnvironment = new HostingEnvironment();
                hostingEnvironment.EnvironmentName = "Development";
                services.AddSingleton(x => hostingEnvironment);
                _serviceProvider = services.BuildServiceProvider();
            }
        }
开发者ID:ResaWildermuth,项目名称:allReady,代码行数:25,代码来源:ActivityApiControllerTests.cs


示例6: Startup

 public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
 {
     var builder = new ConfigurationBuilder(appEnv.ApplicationBasePath)
         .AddJsonFile("config.json")
         .AddEnvironmentVariables();
     Configuration = builder.Build();
 }
开发者ID:heberop,项目名称:tfspanel,代码行数:7,代码来源:Startup.cs


示例7: ConfigureServices

        // This method gets called by a runtime.
        // Use this method to add services to the container
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();


            var path = _app.ApplicationBasePath;
            var config = new ConfigurationBuilder()
            .AddJsonFile($"{path}/config.json")
            .Build();

            string typeName = config.Get<string>("RepositoryType");
            services.AddSingleton(typeof(IBoilerRepository), Type.GetType(typeName));

            object repoInstance = Activator.CreateInstance(Type.GetType(typeName));
            IBoilerRepository repo = repoInstance as IBoilerRepository;
            services.AddInstance(typeof(IBoilerRepository), repo);
            TimerAdapter timer = new TimerAdapter(0, 500);
            BoilerStatusRepository db = new BoilerStatusRepository();
            services.AddInstance(typeof(BoilerMonitor), new BoilerMonitor(repo, timer, db));




            services.AddMvc().AddJsonOptions(options =>
            {
                options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
            });


            // Uncomment the following line to add Web API services which makes it easier to port Web API 2 controllers.
            // You will also need to add the Microsoft.AspNet.Mvc.WebApiCompatShim package to the 'dependencies' section of project.json.
            // services.AddWebApiConventions();

            return services.BuildServiceProvider();
        }
开发者ID:edwardginhands,项目名称:boil.net,代码行数:37,代码来源:Startup.cs


示例8: Startup

 public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
 {
     _basePath = appEnv.ApplicationBasePath;
     Configuration = new ConfigurationBuilder()
         .AddJsonFile(_basePath + "/App_Data/Development.json")
         .Build();
 }
开发者ID:Painyjames,项目名称:Pilarometro,代码行数: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: Startup

 public Startup(IApplicationEnvironment environment)
 {
     Configuration =
         new ConfigurationBuilder(environment.ApplicationBasePath)
             .AddJsonFile("config.json")
             .Build();
 }
开发者ID:adammic,项目名称:aspnet5samples,代码行数:7,代码来源:Startup.cs


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


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


示例13: Main

        public void Main(string[] args)
        {
            var runtimeConfig = new ConfigurationBuilder()
                .AddCommandLine(args)
                .Build();

            var options = new Options();
            runtimeConfig.Bind(options);

            var queueConfig = new ConfigurationBuilder(".")
                .AddJsonFile("queues.json")
                .Build()
                .GetSection(options.QueueType);

            var services = BuildServiceProvider(options, queueConfig);
            var logger = services.GetRequiredService<ILogger<Program>>();
            var handlerFactory = services.GetRequiredService<IMessageHandlerFactory>();
            var queueFactory = services.GetRequiredService<IMessageQueueFactory>();

            var queue = queueFactory.Get(options.ListenTo);
            queue.Listen(msg =>
            {
                var handler = handlerFactory.GetHandler(msg.Body.GetType());
                handler.Handle(msg, queue);
            });
        }
开发者ID:Kieranties,项目名称:MessagingPlayground,代码行数:26,代码来源:Program.cs


示例14: foreach

        IEnumerable<ShellSettings> IShellSettingsManager.LoadSettings()
        {
            var shellSettings = new List<ShellSettings>();

            foreach (var tenant in _appDataFolder.ListDirectories("Sites")) {
                _logger.LogInformation("ShellSettings found in '{0}', attempting to load.", tenant.Name);

                var configurationContainer =
                    new ConfigurationBuilder()
                        .AddJsonFile(_appDataFolder.Combine(tenant.PhysicalPath, string.Format(SettingsFileNameFormat, "json")),
                            true)
                        .AddXmlFile(_appDataFolder.Combine(tenant.PhysicalPath, string.Format(SettingsFileNameFormat, "xml")),
                            true)
                        .AddYamlFile(_appDataFolder.Combine(tenant.PhysicalPath, string.Format(SettingsFileNameFormat, "txt")),
                            false);

                var config = configurationContainer.Build();

                var shellSetting = new ShellSettings(config);
                shellSettings.Add(shellSetting);

                _logger.LogInformation("Loaded ShellSettings for tenant '{0}'", shellSetting.Name);
            }

            return shellSettings;
        }
开发者ID:vebin,项目名称:Brochard,代码行数:26,代码来源:ShellSettingsManager.cs


示例15: CreateBuilder

 private static IConfigurationBuilder CreateBuilder(IApplicationEnvironment appEnv)
 {
     IConfigurationBuilder configurationBuilder = new ConfigurationBuilder(appEnv.ApplicationBasePath)
         .AddJsonFile("Config.json")
         .AddJsonFile("..\\Config.Bus.json");
     return configurationBuilder;
 }
开发者ID:eswann,项目名称:NSB_Perf,代码行数:7,代码来源:ConfigurationFactory.cs


示例16: Startup

 public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
 {
     // Setup configuration sources.
     Configuration = new ConfigurationBuilder(appEnv.ApplicationBasePath)
         .AddJsonFile("config.json")
         .AddEnvironmentVariables().Build();
 }
开发者ID:flcdrg,项目名称:ExtensionGallery,代码行数:7,代码来源:Startup.cs


示例17: Main

        public int Main(string[] args)
        {
            var builder = new ConfigurationBuilder();
            builder.Add(new JsonConfigurationProvider("config.json"));
            var config = builder.Build();
            var webjobsConnectionString = config["Data:AzureWebJobsStorage:ConnectionString"];
            var dbConnectionString = config["Data:DefaultConnection:ConnectionString"];
            if (string.IsNullOrWhiteSpace(webjobsConnectionString))
            {
                Console.WriteLine("The configuration value for Azure Web Jobs Connection String is missing.");
                return 10;
            }

            if (string.IsNullOrWhiteSpace(dbConnectionString))
            {
                Console.WriteLine("The configuration value for Database Connection String is missing.");
                return 10;
            }

            var jobHostConfig = new JobHostConfiguration(config["Data:AzureWebJobsStorage:ConnectionString"]);
            var host = new JobHost(jobHostConfig);
            var methodInfo = typeof(Functions).GetMethods().First();

            host.Call(methodInfo);
            return 0;
        }
开发者ID:dpiessens,项目名称:PartsUnlimited,代码行数:26,代码来源:Program.cs


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


示例19: Main

        public void Main(string[] args)
        {
            _serviceCollection.AddDaniel15();
            var builder = new ConfigurationBuilder(_appEnv.ApplicationBasePath)
                // This is extremely ugly, but the paths differ in dev vs in prod.
                // Need to figure out a nicer way of doing this.
                .AddJsonFile("..\\Daniel15.Web\\config.json", optional: true)
                .AddJsonFile("../../../../../../site/approot/packages/Daniel15.Web/1.0.0/root/config.Production.json", optional: true)
                .AddEnvironmentVariables();
            _serviceCollection.AddDaniel15Config(builder.Build());
            _serviceCollection.AddOptions();
            _serviceProvider = _serviceCollection.BuildServiceProvider();

            var operation = args[0];
            switch (operation)
            {
                case "-disqus":
                    _serviceProvider.GetRequiredService<IDisqusComments>().Sync();
                    break;

                case "-social":
                    ActivatorUtilities.CreateInstance<SocialShareUpdater>(_serviceProvider).Run();
                    break;

                case "-projects":
                    ActivatorUtilities.CreateInstance<ProjectUpdater>(_serviceProvider).Run();
                    break;

                default:
                    throw new Exception("Invalid operation '" + operation + "'");
            }
        }
开发者ID:xb11,项目名称:Website,代码行数:32,代码来源:CronRunner.cs


示例20: Startup

 public Startup(IHostingEnvironment env)
 {
     // Setup configuration sources.
     Configuration = new ConfigurationBuilder()
         .AddJsonFile("config.json")
         .AddEnvironmentVariables().Build();
 }
开发者ID:modulexcite,项目名称:ExtensionGallery,代码行数:7,代码来源:Startup.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ConfigurationModel.Configuration类代码示例发布时间:2022-05-26
下一篇:
C# Configuration.ConfigurationBuilder类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap