當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。