internal I18nTextRepository(IServiceProvider serviceProvider, I18nTextOptions options) { if (options.IsWasm()) { var httpClientFactory = serviceProvider.GetRequiredService <IHttpClientFactory>(); this.HttpClient = httpClientFactory.CreateClient(options.HttpClientName); this.ReadJsonAsTextMapAsync = this.ReadJsonAsTextMapWasmAsync; } else { this.ReadJsonAsTextMapAsync = this.GetReadJsonAsTextMapServerAsync(); } }
internal I18nTextRepository(IServiceProvider serviceProvider) { var runningOnWasm = RuntimeInformation.OSDescription == "web"; if (runningOnWasm) { this.HttpClient = serviceProvider.GetService <HttpClient>(); this.ReadJsonAsTextMapAsync = this.ReadJsonAsTextMapWasmAsync; } else { this.ReadJsonAsTextMapAsync = this.GetReadJsonAsTextMapServerAsync(); } }
internal I18nTextRepository(IServiceProvider serviceProvider, I18nTextOptions options) { var isWasm = options.IsWasm?.Invoke() ?? I18nTextDependencyInjection.IsWasm; if (isWasm) { var httpClientFactory = serviceProvider.GetRequiredService <IHttpClientFactory>(); this.HttpClient = httpClientFactory.CreateClient(options.HttpClientName); this.ReadJsonAsTextMapAsync = this.ReadJsonAsTextMapWasmAsync; } else { this.ReadJsonAsTextMapAsync = this.GetReadJsonAsTextMapServerAsync(); } }
internal I18nText(IServiceProvider serviceProvider) { var runningOnWasm = RuntimeInformation.OSDescription == "web"; if (runningOnWasm) { this.HttpClient = serviceProvider.GetService(typeof(HttpClient)) as HttpClient; this.ReadJsonAsTextMapAsync = this.ReadJsonAsTextMapWasmAsync; } else { this.ReadJsonAsTextMapAsync = this.GetReadJsonAsTextMapServerAsync(); } this.ServiceProvider = serviceProvider; this.JSRuntime = serviceProvider.GetService <IJSRuntime>(); this.Options.GetInitialLanguageAsync = GetInitialLanguageAsync; this.Options.PersistCurrentLanguageAsync = PersistCurrentLanguageAsync; }