src/Dangl.Data.Shared.AspNetCore/SpaUtilities/LocalizedSpaStaticFileExtensions.cs
/// <summary>
/// This configures the necessary services for servicing localized SPAs
/// </summary>
/// <param name="services"></param>
/// <param name="languageCookieName">The cookie under which user locale can be saved</param>
/// <param name="availableLocales">The available locales of the SPA</param>
/// <param name="spaRootPath">The root path under which the SPA resides, e.g. "/dist"</param>
This configures the necessary services for servicing localized SPAs
This configures the necessary services for servicing localized SPAs
public static void AddLocalizedSpaStaticFiles(this IServiceCollection services,
            string languageCookieName,
            string[] availableLocales,
            string spaRootPath)
        {
            services.AddTransient<IUserLanguageService>(serviceProvider =>
            {
                var httpContextAccessor = serviceProvider.GetRequiredService<IHttpContextAccessor>();
                return new UserLanguageService(httpContextAccessor, languageCookieName, availableLocales);
            });
            services.AddTransient<LocalizedSpaStaticFilePathProvider>(serviceProvider =>
            {
                var userLanguageService = serviceProvider.GetRequiredService<IUserLanguageService>();
                return new LocalizedSpaStaticFilePathProvider(userLanguageService, spaRootPath);
            });
        }
public static void AddLocalizedSpaStaticFiles ( this IServiceCollection services , string languageCookieName , string [ ] availableLocales , string spaRootPath ) { services . AddTransient < IUserLanguageService > ( serviceProvider => { var httpContextAccessor = serviceProvider . GetRequiredService < IHttpContextAccessor > ( ) ; return new UserLanguageService ( httpContextAccessor , languageCookieName , availableLocales ) ; } ) ; services . AddTransient < LocalizedSpaStaticFilePathProvider > ( serviceProvider => { var userLanguageService = serviceProvider . GetRequiredService < IUserLanguageService > ( ) ; return new LocalizedSpaStaticFilePathProvider ( userLanguageService , spaRootPath ) ; } ) ; }
This configures the necessary services for servicing localized SPAs
This configures the necessary services for servicing localized SPAs
IServiceCollection
this
languageCookieName
string
The cookie under which user locale can be saved
The cookie under which user locale can be saved
availableLocales
string[]
The available locales of the SPA
The available locales of the SPA
spaRootPath
string
The root path under which the SPA resides, e.g.
The root path under which the SPA resides e . g .
services
None