Пример #1
0
        public static IApplicationBuilder UseDbLocalizationClientsideProvider(this IApplicationBuilder builder)
        {
            AppContext.Configure(builder.ApplicationServices.GetRequiredService <IHttpContextAccessor>());
            _cache = builder.ApplicationServices.GetRequiredService <ICacheManager>();

            var cacheManager = builder.ApplicationServices.GetService <ICacheManager>();

            cacheManager.OnRemove += OnRemove;
            builder.ApplicationServices
            .GetRequiredService <IApplicationLifetime>()
            .ApplicationStopping
            .Register(() => cacheManager.OnRemove -= OnRemove);

            return(builder);
        }
Пример #2
0
        public static IApplicationBuilder UseDbLocalizationClientsideProvider(this IApplicationBuilder builder, string path = "jsl10n")
        {
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException(nameof(path));
            }

            ClientsideConfigurationContext.SetRootPath(path);
            AppContext.Configure(builder.ApplicationServices.GetRequiredService <IHttpContextAccessor>());
            _cache = builder.ApplicationServices.GetRequiredService <ICacheManager>();
            builder.ApplicationServices.GetService <ICacheManager>().OnRemove += OnOnRemove;

            builder.MapWhen(context => context.Request.Path.ToString().StartsWith(ClientsideConfigurationContext.RootPath),
                            _ => { _.UseMiddleware <RequestHandler>(); });

            return(builder);
        }