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


C# Configuration.ConfigurationBuilder类代码示例

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


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


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