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


C# Configuration.AddEnvironmentVariables方法代码示例

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


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

示例1: Configure

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

            // Set up application services
            app.UseServices(services =>
            {
                // 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,代码行数:30,代码来源:Startup.cs

示例2: 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 =>
            {
                // Add EF services to the services container and configure DbContext
                services.ConfigureDataContext(configuration);

                // Register MyShuttle dependencies
                services.ConfigureDependencies();


                //Add Identity services to the services container
                services.AddDefaultIdentity<MyShuttleContext, ApplicationUser, IdentityRole>(configuration);
                services.ConfigureCookieAuthentication(options =>
                {
                    options.LoginPath = new Microsoft.AspNet.Http.PathString("/Carrier/Login");
                });


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

                services
                    .AddSignalR(options =>
                    {
                        options.Hubs.EnableDetailedErrors = true;
                    });
            });

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

            /* Error page middleware displays a nice formatted HTML page for any unhandled exceptions in the request pipeline.
             * Note: ErrorPageOptions.ShowAll to be used only at development time. Not recommended for production.
             */
            app.UseErrorPage(ErrorPageOptions.ShowAll);

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

            app.ConfigureSecurity();

            //Configure SignalR
            app.UseSignalR();

            // Add cookie-based authentication to the request pipeline

            // Add MVC to the request pipeline
            app.ConfigureRoutes();

            MyShuttleDataInitializer.InitializeDatabaseAsync(app.ApplicationServices).Wait();

        }
开发者ID:sriramdasbalaji,项目名称:My-Shuttle-Biz,代码行数:59,代码来源:Startup.cs

示例3: Configure

    public void Configure(IBuilder app)
    {
        app.UseServices(services =>
        {
            /* Adding IConfiguration as a service in the IoC to avoid instantiating Configuration again.
             * Below code demonstrates usage of multiple configuration sources. For instance a setting say 'setting1' is found in both the registered sources, 
             * then the later source will win. By this way a Local config can be overridden by a different setting while deployed remotely.
            */
            var configuration = new Configuration();
            configuration.AddJsonFile("LocalConfig.json");
            configuration.AddEnvironmentVariables(); //All environment variables in the process's context flow in as configuration values.
            services.AddInstance<IConfiguration>(configuration);

            //Add all MVC related services to IoC.
            services.AddMvc();

            /*Add all EF related services to IoC.*/
            services.AddEntityFramework().AddSqlServer();
            services.AddTransient<MusicStoreContext>();

            //Add all Identity related services to IoC. 
            services.AddTransient<DbContext, ApplicationDbContext>();
            services.AddIdentity<ApplicationUser, IdentityRole>(s =>
            {
                s.AddEntity();
            });
            services.AddTransient<SignInManager<ApplicationUser>>();
        });


        /* Error page middleware displays a nice formatted HTML page for any unhandled exceptions in the request pipeline.
         * Note: ErrorPageOptions.ShowAll to be used only at development time. Not recommended for production.
         */
        app.UseErrorPage(ErrorPageOptions.ShowAll);

        //Serves static files in the application.
        app.UseFileServer();

        app.UseCookieAuthentication(new CookieAuthenticationOptions()
        {
            AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
            LoginPath = new PathString("/Account/Login"),
        });

        app.UseMvc(routes =>
        {
            routes.MapRoute(
                null,
                "{controller}/{action}",
                new { controller = "Home", action = "Index" });
        });

        //Populates the MusicStore sample data
        SampleData.InitializeMusicStoreDatabaseAsync(app.ApplicationServices).Wait();
        SampleData.InitializeIdentityDatabaseAsync(app.ApplicationServices).Wait();

        //Creates a Store manager user who can manage the store.
        CreateAdminUser(app.ApplicationServices).Wait();
    }
开发者ID:kaushalp,项目名称:MusicStore,代码行数:59,代码来源:Startup.cs

示例4: Configure

 public void Configure(IBuilder app)
 {
     var config = new Configuration();
     config.AddEnvironmentVariables();
     
     app.Run(async ctx => 
     {
         ctx.Response.ContentType = "text/plain";
         DumpConfig(ctx.Response, config);
     });
 }
开发者ID:boro2g,项目名称:AspNetVNextSamples,代码行数:11,代码来源:Startup.cs

示例5: Configure

    public void Configure(IApplicationBuilder app)
    {
        var config = new Configuration();
        config.AddIniFile("Config.Sources.ini");
        config.AddEnvironmentVariables();

        app.Run(async ctx =>
        {
            ctx.Response.ContentType = "text/plain";
            await DumpConfig(ctx.Response, config);
        });
    }
开发者ID:Tragetaschen,项目名称:Entropy,代码行数:12,代码来源:Startup.cs

示例6: 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:ecalderonTX,项目名称:generator-aspnet,代码行数:16,代码来源:startup.cs

示例7: Configure

    public void Configure(IBuilder app)
    {
        var config = new Configuration();
        config.AddIniFile("Config.Sources.ini");
        config.AddEnvironmentVariables();

        app.Run(async ctx =>
        {
            ctx.Response.ContentType = "text/plain";

            Func<String, String> formatKeyValue = key => "[" + key + "] " + config.Get(key) + "\r\n\r\n";
            await ctx.Response.WriteAsync(formatKeyValue("Services:One.Two"));
            await ctx.Response.WriteAsync(formatKeyValue("Services:One.Two:Six"));
            await ctx.Response.WriteAsync(formatKeyValue("Data:DefaultConnecection:ConnectionString"));
            await ctx.Response.WriteAsync(formatKeyValue("Data:DefaultConnecection:Provider"));
            await ctx.Response.WriteAsync(formatKeyValue("Data:Inventory:ConnectionString"));
            await ctx.Response.WriteAsync(formatKeyValue("Data:Inventory:Provider"));
            await ctx.Response.WriteAsync(formatKeyValue("PATH"));
            await ctx.Response.WriteAsync(formatKeyValue("COMPUTERNAME"));
        });
    }
开发者ID:kulmugdha,项目名称:Entropy,代码行数:21,代码来源:Startup.cs


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