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


C# Configuration.AddEnvironmentVariables方法代码示例

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


在下文中一共展示了Configuration.AddEnvironmentVariables方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConfigureServices

        /// <summary>
        /// Sets up the DI container. Loads types dynamically (http://docs.autofac.org/en/latest/register/scanning.html)
        /// </summary>
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();

            /* TODO: #10
            services.AddCaching();
            services.AddSession();

            services.ConfigureSession(o =>
            {
                o.IdleTimeout = TimeSpan.FromMinutes(5);
            });*/

            services.AddTransient<WopiAuthorizationAttribute>();

            // Autofac resolution
            var builder = new ContainerBuilder();

            // Configuration
            Configuration configuration = new Configuration();
            configuration.AddEnvironmentVariables();
            builder.RegisterInstance(configuration).As<IConfiguration>().SingleInstance();

            // File provider implementation
            var providerAssembly = configuration.Get("WopiFileProviderAssemblyName");
            var assembly = AppDomain.CurrentDomain.Load(new AssemblyName(providerAssembly));
            builder.RegisterAssemblyTypes(assembly).AsImplementedInterfaces();

            builder.Populate(services);
            var container = builder.Build();
            return container.Resolve<IServiceProvider>();
        }
开发者ID:FeodorFitsner,项目名称:WopiHost,代码行数:35,代码来源:Startup.cs

示例2: Configure

        public void Configure(IApplicationBuilder app)
        {
            var config = new Configuration();
            config.AddEnvironmentVariables();
            config.AddJsonFile("config.json");
            config.AddJsonFile("config.dev.json", true);
            config.AddUserSecrets();

            var password = config.Get("password");

            if (config.Get<bool>("RecreateDatabase"))
            {
                var context = app.ApplicationServices.GetService<Models.BlogDataContext>();
                context.Database.EnsureDeleted();
                System.Threading.Thread.Sleep(2000);
                context.Database.EnsureCreated();
            }


            if (config.Get<bool>("debug"))
            {
                app.UseErrorPage();
                app.UseRuntimeInfoPage();
            }
            else
            {
                app.UseErrorHandler("/home/error");
            }

            app.UseMvc(routes => routes.MapRoute(
                "Default", "{controller=Home}/{action=Index}/{id?}"));

            app.UseFileServer();
        }
开发者ID:lukehammer,项目名称:AspNetBlog,代码行数:34,代码来源:Startup.cs

示例3: Configure

        public void Configure(IBuilder app)
        {
            // Setup configuration sources
            var configuration = new Configuration();
            configuration.AddEnvironmentVariables();

            // Set up application services
            app.UseServices(services =>
            {
                // Add MVC services to the services container
                services.AddMvc();
            });

            // Enable Browser Link support
            app.UseBrowserLink();

            // Add static files to the request pipeline
            app.UseStaticFiles();

            // Add MVC to the request pipeline
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "Home", action = "Index" });
            });
        }
开发者ID:LeoLcy,项目名称:MVC6Recipes,代码行数:28,代码来源:Startup.cs

示例4: Startup

        public Startup(
            IHostingEnvironment hostingEnvironment,
            ILoggerFactory loggerFactory)
        {
            _logger = loggerFactory.CreateLogger<Startup>();

            var configuration = new Configuration();
            configuration.AddJsonFile("config.json");
            configuration.AddEnvironmentVariables();
            var loggingConfiguration = configuration.GetSubKey("Logging");

            var serilog = new LoggerConfiguration()
                .MinimumLevel.Verbose()
                .Enrich.WithMachineName()
                .Enrich.WithProcessId()
                .Enrich.WithThreadId();

            if (string.Equals(hostingEnvironment.EnvironmentName, "Development", StringComparison.OrdinalIgnoreCase))
            {
                serilog.WriteTo.ColoredConsole();
            }

            string elasticSearchConnectionString;
            if (loggingConfiguration.TryGet("ElasticSearch:Server", out elasticSearchConnectionString))
            {
                serilog.WriteTo.ElasticSearch(node: new Uri(elasticSearchConnectionString));
            }

            loggerFactory.AddSerilog(serilog);
        }
开发者ID:Tragetaschen,项目名称:Entropy,代码行数:30,代码来源:Startup.cs

示例5: Startup

 public Startup(IHostingEnvironment env)
 {
     // Setup configuration sources.
     var configuration = new Configuration();
     configuration.AddEnvironmentVariables();
     Configuration = configuration;
 }
开发者ID:jonnoaud,项目名称:FrontEndSeed,代码行数:7,代码来源:Startup.cs

示例6: Configure

        public void Configure(IBuilder app)
        {
            // Setup configuration sources
            var configuration = new Configuration();
            configuration.AddEnvironmentVariables();

            app.UseOwin();

            // Set up application services
            app.UseServices(services =>
            {                // Add MVC services to the services container
                services.AddMvc();
                services.SetupOptions<MvcOptions>(options => {
                    System.Diagnostics.Debug.WriteLine(options.OutputFormatters.Select(item => item.GetType().Name));

                    options.OutputFormatters.RemoveAt(0);
                });
            });

            // Add static files to the request pipeline
            app.UseStaticFiles();

            // Add MVC to the request pipeline
            app.UseMvc(routes =>
            {
                //routes.MapRoute(
                //    name: "default",
                //    template: "{controller}/{action}/{id?}",
                //    defaults: new { controller = "Home", action = "Index" });

                routes.MapRoute(
                    name: "api",
                    template: "{controller}/{id?}");
            });
        }
开发者ID:niklaslundberg,项目名称:VisualStudio-UF,代码行数:35,代码来源:Startup.cs

示例7: Startup

        public Startup(IHostingEnvironment env)
        {
            var configuration = new Configuration()
                  .AddJsonFile("config.json");

            configuration.AddEnvironmentVariables();
            Configuration = configuration;
        }
开发者ID:huamanhtuyen,项目名称:FindAroundWS,代码行数:8,代码来源:Startup.cs

示例8: Configure

        public void Configure(IApplicationBuilder app)
        {
            // Setup configuration sources
            var configuration = new Configuration();
            configuration.AddJsonFile("config.json");
            configuration.AddEnvironmentVariables();

            // Set up application services
            app.UseServices(services =>
            {
                services.AddAssembly(this);

                // Add EF services to the services container
                services.AddEntityFramework()
                    .AddSqlServer();

                // Configure DbContext
                services.SetupOptions<DbContextOptions>(options =>
                {
                    options.UseSqlServer(configuration.Get("Data:DefaultConnection:ConnectionString"));
                });
                
                //// Add Identity services to the services container
                //services.AddIdentitySqlServer<ApplicationDbContext, ApplicationUser>()
                //    .AddAuthentication();

                // Add MVC services to the services container
                services.AddMvc();

                services.AddTransient(typeof(IService1), typeof(Service1));
            });

            // Enable Browser Link support
            //app.UseBrowserLink();

            // Add static files to the request pipeline
            app.UseStaticFiles();

            // Add cookie-based authentication to the request pipeline
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = ClaimsIdentityOptions.DefaultAuthenticationType,
                LoginPath = new PathString("/Account/Login"),
            });

            // Add MVC to the request pipeline
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default", 
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "Home", action = "Index" });

                routes.MapRoute(
                    name: "api",
                    template: "{controller}/{id?}");
            });
        }
开发者ID:david-driscoll,项目名称:DependencyInjection.Annotations,代码行数:58,代码来源:Startup.cs

示例9: Startup

        public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
        {
            // Setup configuration sources.

            var builder = new Configuration()
                .AddJsonFile("config.json");

            builder.AddEnvironmentVariables();
            Configuration = builder;
        }
开发者ID:luckycadow,项目名称:beerfish,代码行数:10,代码来源:Startup.cs

示例10: ConfigSetup

        public ConfigSetup()
        {
            // Make individual calls to AddXXX extension methods
            var config = new Configuration();
            config.AddJsonFile("config.json");
            config.AddEnvironmentVariables();

            // Fluent configuration
            var configFluent = new Configuration()
                .AddJsonFile("config.json")
                .AddEnvironmentVariables();
        }
开发者ID:bigfont,项目名称:Docs,代码行数:12,代码来源:ConfigSetup.cs

示例11: Configure

        public void Configure(IBuilder app)
        {
            // Enable Browser Link support
            app.UseBrowserLink();

            // Setup configuration sources
            var configuration = new Configuration();

            //configuration.AddIniFile("config.ini");
            configuration.AddJsonFile("config.json");
            configuration.AddEnvironmentVariables();

            //app.Run(async context =>
            //{
            //    await context.Response.WriteAsync(configuration.Get("Data:Configuration"));
            //});

            app.Run(async context =>
            {
                var asm = Assembly.Load(new AssemblyName("klr.host"));
                var assemblyVersion = asm.GetCustomAttribute<AssemblyInformationalVersionAttribute>();

                await context.Response.WriteAsync(assemblyVersion.InformationalVersion);
            });

            // Set up application services
            app.UseServices(services =>
            {
                // Add EF services to the services container
                services.AddEntityFramework().AddInMemoryStore();
                services.AddScoped<PersonContext>();

                // Add MVC services to the services container
                services.AddMvc();
            });

            // Add static files to the request pipeline
            app.UseStaticFiles();

            // Add MVC to the request pipeline
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default", 
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "Home", action = "Index" });

                routes.MapRoute(
                    name: "api",
                    template: "{controller}/{id?}");
            });
        }
开发者ID:julid29,项目名称:confsamples,代码行数:52,代码来源:Startup.cs

示例12: Startup

        public Startup(IHostingEnvironment env)
        {
            System.Console.WriteLine(env.EnvironmentName);

            // Setup configuration sources.
            var configuration = new Configuration()
                .AddJsonFile("config.json")
                .AddJsonFile($"config.{env.EnvironmentName}.json", optional: true);

            configuration.AddEnvironmentVariables();

            Configuration = configuration;
        }
开发者ID:dmasubuchi,项目名称:win10Challenge,代码行数:13,代码来源:Startup.cs

示例13: Startup

        public Startup(IHostingEnvironment env)
        {
            // Setup configuration sources.
            var configuration = new Configuration()
                .AddJsonFile("config.json")
                .AddJsonFile($"config.{env.EnvironmentName}.json", optional: true);

            if (env.IsEnvironment("Development"))
            {
                configuration.AddUserSecrets();
            }
            configuration.AddEnvironmentVariables();
            Configuration = configuration;
        }
开发者ID:johndelfGM,项目名称:NerdDinner,代码行数:14,代码来源:Startup.cs

示例14: Startup

        public Startup(IHostingEnvironment env) {
            // Setup configuration sources.
            var configuration = new Configuration()
                .AddJsonFile("config.json")
                .AddJsonFile($"config.{env.EnvironmentName}.json", optional: true);

            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
                configuration.AddUserSecrets();
            }
            configuration.AddEnvironmentVariables();
            Configuration = configuration;
        }
开发者ID:beginor,项目名称:practice,代码行数:14,代码来源:Startup.cs

示例15: Main

        public void Main(string[] args)
        {
            var config = new Configuration();
            if (File.Exists(HostingIniFile))
            {
                config.AddIniFile(HostingIniFile);
            }
            config.AddEnvironmentVariables();
            config.AddCommandLine(args);

            var context = new HostingContext()
            {
                Configuration = config,
                ServerFactoryLocation = config.Get("server"),
                ApplicationName = config.Get("app")
            };

            var engine = new HostingEngine(_serviceProvider);

            var serverShutdown = engine.Start(context);
            var loggerFactory = context.ApplicationServices.GetRequiredService<ILoggerFactory>();
            var appShutdownService = context.ApplicationServices.GetRequiredService<IApplicationShutdown>();
            var shutdownHandle = new ManualResetEvent(false);

            appShutdownService.ShutdownRequested.Register(() =>
            {
                try
                {
                    serverShutdown.Dispose();
                }
                catch (Exception ex)
                {
                    var logger = loggerFactory.CreateLogger<Program>();
                    logger.LogError("Dispose threw an exception.", ex);
                }
                shutdownHandle.Set();
            });

            var ignored = Task.Run(() =>
            {
                Console.WriteLine("Started");
                Console.ReadLine();
                appShutdownService.RequestShutdown();
            });

            shutdownHandle.WaitOne();
        }
开发者ID:Guruanth,项目名称:Hosting,代码行数:47,代码来源:Program.cs


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