// This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { var supportedCultures = new[] { "en", "es" }; var opt = new RequestLocalizationOptions { DefaultRequestCulture = new RequestCulture("en"), }; opt.AddSupportedCultures(supportedCultures); opt.AddSupportedUICultures(supportedCultures); services.AddSingleton(opt); services.AddMvc(); services.AddRazorPages(); services.AddServerSideBlazor(opt => opt.DetailedErrors = true); services.AddLocalization(options => { options.ResourcesPath = "Resources"; }); services.AddSingleton <IPhotoLabelerService, PhotoLabelerService>(); services.AddSingleton <IMenuService, MenuService>(); services.AddSingleton <IDbConnection>((serviceProvider) => { var connectionStringBuilder = new SqliteConnectionStringBuilder { DataSource = "./appconfig.db" }; var connection = new SqliteConnection(connectionStringBuilder.ConnectionString); return(connection); }); services.AddSingleton <IAppConfigRepository, AppConfigRepository>(); }
public void Configuration(IAppBuilder app) { var options = new RequestLocalizationOptions() .UseUnityInjection(UnityConfig.Container); options.AddSupportedCultures("en-US", "de"); options.AddSupportedUICultures("en-US", "de"); options.RequestCultureProviders.Clear(); options.AddInjectedProvider <TestCultureProvider>(); app.UseRequestLocalization(options); }
public void Configuration(IAppBuilder app) { var builder = new ContainerBuilder(); builder.RegisterType <TestCultureProvider>().InstancePerLifetimeScope(); var container = builder.Build(); app.UseAutofacMiddleware(container); var options = new RequestLocalizationOptions() .UseAutofacInjection(); options.AddSupportedCultures("en-US", "de"); options.AddSupportedUICultures("en-US", "de"); options.RequestCultureProviders.Clear(); options.AddInjectedProvider <TestCultureProvider>(); app.UseRequestLocalization(options); }