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


C# IApplicationBuilder.UseRequestLocalization方法代码示例

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


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

示例1: Configure

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseIISPlatformHandler();
            app.UseStaticFiles();

            app.UseRequestLocalization(new RequestLocalizationOptions()
            {
                SupportedCultures = new List<CultureInfo>
                {
                    new CultureInfo("fr"),
                }
            }, new RequestCulture("fr"));

            app.UseMvc();
        }
开发者ID:sebastieno,项目名称:sebastienollivier.fr,代码行数:28,代码来源:Startup.cs

示例2: Configure

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            var locOptions = app.ApplicationServices.GetService<IOptions<RequestLocalizationOptions>>();
            app.UseRequestLocalization(locOptions.Value);

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseBrowserLink();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
开发者ID:damienbod,项目名称:AspNet5Localization,代码行数:28,代码来源:Startup.cs

示例3: ConfigureRequestLocalization

        protected virtual void ConfigureRequestLocalization(IApplicationBuilder app)
        {
            using (var languageManager = AbpBootstrapper.IocManager.ResolveAsDisposable<ILanguageManager>())
            {
                var supportedCultures = languageManager.Object
                    .GetLanguages()
                    .Select(l => new CultureInfo(l.Name))
                    .ToArray();

                var defaultCulture = new RequestCulture(
                    languageManager.Object
                        .GetLanguages()
                        .FirstOrDefault(l => l.IsDefault)
                        ?.Name
                );

                var options = new RequestLocalizationOptions
                {
                    DefaultRequestCulture = defaultCulture,
                    SupportedCultures = supportedCultures,
                    SupportedUICultures = supportedCultures
                };

                app.UseRequestLocalization(options);
            }
        }
开发者ID:carldai0106,项目名称:aspnetboilerplate,代码行数:26,代码来源:AbpStartup.cs

示例4: Configure

        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.MinimumLevel = LogLevel.Information;
            loggerFactory.AddConsole();
            loggerFactory.AddDebug();

            var requestLocalizationOptions = new RequestLocalizationOptions
            {  
                SupportedCultures = new List<CultureInfo>
                {
                    new CultureInfo("en-US"),
                    new CultureInfo("de-CH"),
                    new CultureInfo("fr-CH"),

                    new CultureInfo("it-CH")
                },
                SupportedUICultures = new List<CultureInfo>
                {
                    new CultureInfo("en-US"),
                    new CultureInfo("de-CH"),
                    new CultureInfo("fr-CH"),
                    new CultureInfo("it-CH")
                }
            };

            app.UseRequestLocalization(requestLocalizationOptions,  new RequestCulture("en-US"));

            app.UseIISPlatformHandler();

            app.UseStaticFiles();

            app.UseMvc();
            app.UseStaticFiles();
        }
开发者ID:jmurkoth,项目名称:LocalizationIssue,代码行数:34,代码来源:Startup.cs

示例5: Configure

        public void Configure(IApplicationBuilder app)
        {
            app.UseStatusCodePages();
            app.UseFileServer();

            if (_autoFac)
            {
                app.UseMiddleware<MonitoringMiddlware>();
            }
            app.UseRequestLocalization();

            app.UseSession();
            app.UseMvc(routes =>
            {
                routes.MapRoute("areaRoute", "{area:exists}/{controller}/{action}");
                routes.MapRoute(
                    "controllerActionRoute",
                    "{controller}/{action}",
                    new { controller = "Home", action = "Index" },
                    constraints: null,
                    dataTokens: new { NameSpace = "default" });

                routes.MapRoute(
                    "controllerRoute",
                    "{controller}",
                    new { controller = "Home" });
            });
        }
开发者ID:ryanbrandenburg,项目名称:Mvc,代码行数:28,代码来源:Startup.cs

示例6: Configure

        public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole((category, level) =>
            {
                if (category.StartsWith("Microsoft."))
                {
                    return level >= LogLevel.Information;
                }

                return level >= LogLevel.Verbose;
            });

            app.UseStatusCodePages();
            app.UseFileServer();

            app.UseRequestLocalization(new RequestCulture("en-US"));

            app.UseSession();
            app.UseMvc(routes =>
            {
                routes.MapRoute("areaRoute", "{area:exists}/{controller}/{action}");
                routes.MapRoute(
                    "controllerActionRoute",
                    "{controller}/{action}",
                    new { controller = "Home", action = "Index" },
                    constraints: null,
                    dataTokens: new { NameSpace = "default" });

                routes.MapRoute(
                    "controllerRoute",
                    "{controller}",
                    new { controller = "Home" });
            });
        }
开发者ID:huoxudong125,项目名称:Mvc,代码行数:34,代码来源:Startup.cs

示例7: ConfigureRequestLocalization

        private static void ConfigureRequestLocalization(IApplicationBuilder app)
        {
            using (var languageManager = app.ApplicationServices.GetRequiredService<IIocResolver>().ResolveAsDisposable<ILanguageManager>())
            {
                var defaultLanguage = languageManager.Object
                    .GetLanguages()
                    .FirstOrDefault(l => l.IsDefault);

                if (defaultLanguage == null)
                {
                    return;
                }

                var supportedCultures = languageManager.Object
                    .GetLanguages()
                    .Select(l => new CultureInfo(l.Name))
                    .ToArray();

                var defaultCulture = new RequestCulture(defaultLanguage.Name);

                var options = new RequestLocalizationOptions
                {
                    DefaultRequestCulture = defaultCulture,
                    SupportedCultures = supportedCultures,
                    SupportedUICultures = supportedCultures
                };

                app.UseRequestLocalization(options);
            }
        }
开发者ID:ZhaoRd,项目名称:aspnetboilerplate,代码行数:30,代码来源:AbpApplicationBuilderExtensions.cs

示例8: Configure

        public void Configure(IApplicationBuilder app)
        {
            app.UseRequestLocalization();

            // Add MVC to the request pipeline
            app.UseMvcWithDefaultRoute();
        }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:7,代码来源:Startup.cs

示例9: Configure

        public void Configure(IApplicationBuilder app)
        {
            app.UseCultureReplacer();

            app.UseRequestLocalization();
            
            app.UseMvcWithDefaultRoute();
        }
开发者ID:ryanbrandenburg,项目名称:Mvc,代码行数:8,代码来源:Startup.cs

示例10: Configure

        public void Configure(IApplicationBuilder app)
        {
            app.UseRequestLocalization(new RequestLocalizationOptions
            {
                // Ignore ambient and client locale. Use same values as ReplaceCultureAttribute / CultureReplacerMiddleware.
                DefaultRequestCulture = new RequestCulture("en-GB", "en-US"),
                RequestCultureProviders = new List<IRequestCultureProvider>()
            });

            app.UseMvc();
        }
开发者ID:cemalshukriev,项目名称:Mvc,代码行数:11,代码来源:Startup.cs

示例11: Configure

        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole();
            loggerFactory.AddDebug();

            var locOptions = app.ApplicationServices.GetService<IOptions<RequestLocalizationOptions>>();
            app.UseRequestLocalization(locOptions.Value);

            app.UseStaticFiles();

            app.UseMvc();
        }
开发者ID:ciker,项目名称:AspNet5Localization,代码行数:12,代码来源:Startup.cs

示例12: Configure

        public void Configure(IApplicationBuilder app)
        {
            // Default to en-CA locale and make sure nothing overrides that choice.
            var options = new RequestLocalizationOptions
            {
                DefaultRequestCulture = new RequestCulture("en-CA"),
            };
            options.RequestCultureProviders.Clear();
            app.UseRequestLocalization(options);

            app.UseStaticFiles();
            app.UseMvcWithDefaultRoute();
        }
开发者ID:tuespetre,项目名称:mvc-sandbox,代码行数:13,代码来源:Startup.cs

示例13: Configure

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            // Configure the Localization middleware
            var culture = new RequestCulture(new CultureInfo("en-US"), new CultureInfo("en-US"));
            app.UseRequestLocalization(culture);

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");

                // For more details on creating database during deployment see http://go.microsoft.com/fwlink/?LinkID=615859
                try
                {
                    using (var serviceScope = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>()
                        .CreateScope())
                    {
                        serviceScope.ServiceProvider.GetService<ApplicationDbContext>()
                             .Database.Migrate();
                    }
                }
                catch { }
            }

            app.UseIISPlatformHandler(options => options.AuthenticationDescriptions.Clear());

            app.UseStaticFiles();

            app.UseIdentity();

            // To configure external authentication please see http://go.microsoft.com/fwlink/?LinkID=532715

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
开发者ID:elvisdelima,项目名称:localizationApp,代码行数:47,代码来源:Startup.cs

示例14: Configure

        public void Configure(IApplicationBuilder applicationBuilder, IHostingEnvironment hostingEnvironment)
        {
            applicationBuilder.UseSession();

              if (hostingEnvironment.IsEnvironment("Development"))
              {
            applicationBuilder.UseStatusCodePages();
            applicationBuilder.UseErrorPage();
            applicationBuilder.UseBrowserLink();
              }

              else
              {
            applicationBuilder.UseStatusCodePages();
            applicationBuilder.UseErrorHandler("/Default/Error");
              }

              applicationBuilder.UseStaticFiles();
              applicationBuilder.UseCookieAuthentication(options => {
            options.AuthenticationScheme = CookieAuthenticationDefaults.AuthenticationScheme;
            options.AutomaticAuthentication = true;
            options.CookieName = "PLATFORMUS";
            options.ExpireTimeSpan = new System.TimeSpan(1, 0, 0);
            options.LoginPath = new PathString("/Backend/Account/SignIn");
              });

              RequestLocalizationOptions requestLocalizationOptions = new RequestLocalizationOptions();

              requestLocalizationOptions.RequestCultureProviders.Insert(0, new RouteValueRequestCultureProvider());
              applicationBuilder.UseRequestLocalization(requestLocalizationOptions);

              applicationBuilder.UseMvc(routes =>
            {
              // Backend
              routes.MapRoute(name: "Backend Create", template: "{area:exists}/{controller=Default}/create", defaults: new { action = "CreateOrEdit" });
              routes.MapRoute(name: "Backend Edit", template: "{area:exists}/{controller=Default}/edit/{id}", defaults: new { action = "CreateOrEdit" });
              routes.MapRoute(name: "Backend Default", template: "{area:exists}/{controller=Default}/{action=Index}/{id?}");

              // Frontend
              //routes.MapRoute(name: "Standard", template: "{controller=Default}/{action=Index}/{id?}", defaults: new { }, constraints: new { controller = " " });
              routes.MapRoute(name: "Default", template: "{culture=en}/{*url}", defaults: new { controller = "Default", action = "Index" });
            }
              );
        }
开发者ID:OlegDokuka,项目名称:Platformus,代码行数:44,代码来源:Startup.cs

示例15: Configure

        public void Configure(IApplicationBuilder applicationBuilder)
        {
            RequestLocalizationOptions requestLocalizationOptions = new RequestLocalizationOptions();

              requestLocalizationOptions.SupportedCultures = new List<CultureInfo>
              {
            new CultureInfo("en"),
            new CultureInfo("uk")
              };

              requestLocalizationOptions.SupportedUICultures = new List<CultureInfo>
              {
            new CultureInfo("en"),
            new CultureInfo("uk")
              };

              requestLocalizationOptions.RequestCultureProviders.Insert(0, new RouteValueRequestCultureProvider());
              applicationBuilder.UseRequestLocalization(requestLocalizationOptions, new RequestCulture("en"));
        }
开发者ID:rajendra1809,项目名称:Platformus,代码行数:19,代码来源:GlobalizationExtension.cs


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