public static async Task Main(string[] args) { var builder = WebAssemblyHostBuilder.CreateDefault(args); AddLoggingAndApplicationInsights(builder); builder.RootComponents.Add <App>("app"); builder.Services.AddSingleton(new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); builder.Services.AddScoped(typeof(AccountClaimsPrincipalFactory <RemoteUserAccount>), typeof(RolesAccountClaimsPrincipalFactory)); // multiple roles workaround builder.Services.AddApiAuthorization(); builder.Services.AddLocalization(); builder.Services.AddGeneratedResourceWrappers(); builder.Services.AddBlazoredLocalStorage(); builder.Services.AddHxMessenger(); builder.Services.AddHxMessageBoxHost(); SetHxComponents(); builder.Services.AddScoped <IContactReferenceDataStore, ContactReferenceDataStore>(); AddGrpcClient(builder); WebAssemblyHost webAssemblyHost = builder.Build(); await SetLanguage(webAssemblyHost); await webAssemblyHost.RunAsync(); }
public async static Task SetDefaultCultureAsync(this WebAssemblyHost host) { CultureInfo culture; try { var jsInterop = host.Services.GetRequiredService <IJSRuntime>(); var result = await jsInterop.InvokeAsync <string>("selectedCulture.get"); if (string.IsNullOrWhiteSpace(result)) { result = await jsInterop.InvokeAsync <string>("browserCulture.get"); } if (!string.IsNullOrWhiteSpace(result)) { var foundCulture = AppCultures.SupportedCultures.FirstOrDefault(x => x.Name == result || x.TwoLetterISOLanguageName.ToLower() == result.ToLower()); culture = foundCulture ?? new CultureInfo(result); } else { culture = new CultureInfo("en-US"); } } catch (Exception exception) { culture = new CultureInfo("en-US"); Console.WriteLine("Unable to get user language : " + exception.Message); } CultureInfo.DefaultThreadCurrentCulture = culture; CultureInfo.DefaultThreadCurrentUICulture = culture; CultureInfo.CurrentCulture = culture; CultureInfo.CurrentUICulture = culture; }
public async static Task SetCurrentTheme(this WebAssemblyHost host, AppState appState) { var jsInterop = host.Services.GetRequiredService <IJSRuntime>(); var result = await jsInterop.InvokeAsync <string>("currentTheme.get"); appState.SetTheme(result); }
public static async Task Main(string[] args) { var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.RootComponents.Add <App>("app"); builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); //builder.Services.AddScoped<IPhilipsHueService, PhilipsHueService>(); builder.Services.AddScoped <IPhilipsHueService, DesignPhilipsHueService>(); builder.Services.AddBlazorise(options => { options.ChangeTextOnKeyPress = true; }) .AddBootstrapProviders() .AddFontAwesomeIcons(); WebAssemblyHost host = builder.Build(); host.Services .UseBootstrapProviders() .UseFontAwesomeIcons(); await host.RunAsync(); }
public static WebAssemblyHost EnableTransientDisposableDetection( this WebAssemblyHost webAssemblyHost) { webAssemblyHost.Services .GetRequiredService <ThrowOnTransientDisposable>().ShouldThrow = true; return(webAssemblyHost); }
private static void ConfigureCulture(WebAssemblyHost host) { // In the absence of a specified value, we want the culture to be en-US so that the tests for bind can work consistently. var culture = new CultureInfo("en-US"); Uri uri = null; try { uri = new Uri(host.Services.GetService <NavigationManager>().Uri); } catch (ArgumentException) { // Some of our tests set this application up incorrectly so that querying NavigationManager.Uri throws. } if (uri != null && HttpUtility.ParseQueryString(uri.Query)["culture"] is string cultureName) { culture = new CultureInfo(cultureName); } // CultureInfo.CurrentCulture is async-scoped and will not affect the culture in sibling scopes. // Use CultureInfo.DefaultThreadCurrentCulture instead to modify the application's default scope. CultureInfo.DefaultThreadCurrentCulture = culture; CultureInfo.DefaultThreadCurrentUICulture = culture; }
public static async Task Main(string[] args) { WebAssemblyHostBuilder builder = WebAssemblyHostBuilder.CreateDefault(args); builder.RootComponents.Add <App>("#app"); builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); builder.Services.AddOidcAuthentication(options => { builder.Configuration.Bind("Local", options.ProviderOptions); //options.ProviderOptions.Authority = "https://accounts.google.com/"; //options.ProviderOptions.RedirectUri = "https://localhost:44333/authentication/login-callback"; //options.ProviderOptions.PostLogoutRedirectUri = "https://localhost:44333/authentication/logout-callback"; //options.ProviderOptions.ClientId = "953393400208-sab1pb4ga5jeie0g50ft6uumf4uqa6in.apps.googleusercontent.com"; options.ProviderOptions.ResponseType = "id_token token"; //options.ProviderOptions.DefaultScopes.Add("https://www.googleapis.com/auth/drive"); // See, edit, create, and delete all of your Google Drive files //options.ProviderOptions.DefaultScopes.Add("https://www.googleapis.com/auth/drive.appdata"); // See, create, and delete its own configuration data in your Google Drive options.ProviderOptions.DefaultScopes.Add("https://www.googleapis.com/auth/drive.file"); // See, edit, create, and delete only the specific Google Drive files you use with this app //options.ProviderOptions.DefaultScopes.Add("https://www.googleapis.com/auth/drive.install"); // Connect itself to your Google Drive }); builder.Services.AddServices(); WebAssemblyHost host = builder.Build(); await host.Services.UseServices(); await host.RunAsync(); }
public static async Task Main(string[] args) { var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.RootComponents.Add <App>("#app"); builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); ConfigureServices(builder.Services); WebAssemblyHost host = builder.Build(); var js = host.Services.GetRequiredService <IJSRuntime>(); string culture = await js.InvokeAsync <string>("getFromLocalStorage", "culture"); CultureInfo selectedCulture; if (culture == null) { selectedCulture = new CultureInfo("en-US"); } else { selectedCulture = new CultureInfo(culture); } CultureInfo.DefaultThreadCurrentCulture = selectedCulture; CultureInfo.DefaultThreadCurrentUICulture = selectedCulture; await host.RunAsync(); //await builder.Build().RunAsync(); }
public static void UseDragonFlyClient(this WebAssemblyHost host) { var componentManager = host.Services.GetRequiredService <FieldComponentManager>(); componentManager.RegisterField <ArrayFieldView>(); componentManager.RegisterField <AssetFieldView>(); componentManager.RegisterField <BoolFieldView>(); componentManager.RegisterField <DateFieldView>(); componentManager.RegisterField <EmbedFieldView>(); componentManager.RegisterField <FloatFieldView>(); componentManager.RegisterField <IntegerFieldView>(); componentManager.RegisterField <ReferenceFieldView>(); componentManager.RegisterField <SlugFieldView>(); componentManager.RegisterField <StringFieldView>(); componentManager.RegisterField <TextAreaFieldView>(); componentManager.RegisterField <XHtmlFieldView>(); componentManager.RegisterField <XmlFieldView>(); componentManager.RegisterOptions <ArrayFieldOptionsView>(); componentManager.RegisterOptions <AssetFieldOptionsView>(); componentManager.RegisterOptions <BoolFieldOptionsView>(); componentManager.RegisterOptions <EmbedFieldOptionsView>(); componentManager.RegisterOptions <FloatFieldOptionsView>(); componentManager.RegisterOptions <IntegerFieldOptionsView>(); componentManager.RegisterOptions <StringFieldOptionsView>(); //assets var assetMetadataManager = host.Services.GetRequiredService <AssetMetadataComponentManager>(); assetMetadataManager.Register <ImageMetadataView>(); }
public static async Task Main(string[] args) { WebAssemblyHost host = CreateHostBuilder(args).Build(); await Initialize(host); await host.RunAsync(); }
public static async Task PreLoad(this WebAssemblyHost host) { var messageService = host.Services.GetRequiredService <IMessageService>(); await messageService.InitializeAsync(); var gamePlayService = host.Services.GetRequiredService <IGamePlayService>(); await gamePlayService.PreLoadPlayerSlotAvailable(); }
public static void Configure(WebAssemblyHost host) { host.Services .UseBootstrapProviders() .UseFontAwesomeIcons(); host.UseLoadingBar(); }
public static WebAssemblyHost LaunchBasicServices(this WebAssemblyHost host) { var refresher = host.Services.GetService <IHackSystemAuthenticationTokenRefresher>(); refresher.StartRefresher(); return(host); }
private static void SubscribeHttpClientInterceptorEvents(WebAssemblyHost host) { // Subscribe IHttpClientInterceptor's events. var httpInterceptor = host.Services.GetService <IHttpClientInterceptor>(); httpInterceptor.BeforeSend += OnBeforeSend; httpInterceptor.AfterSendAsync += OnAfterSendAsync; }
/// <summary> /// Ensure "TimeZoneInfo.GetSystemTimeZones()" /// </summary> public static WebAssemblyHost UseSystemTimeZones(this WebAssemblyHost host) { if (TimeZoneInfo.GetSystemTimeZones().Count == 0) { TimeZoneKit.TimeZoneKit.SetSystemTimeZones(TimeZoneKit.TimeZoneKit.CreateSystemTimeZones()); } return(host); }
public static WebAssemblyHost UseJssBlazorComponents(this WebAssemblyHost host) { // Blazor WebAssembly doesn't currently include any time zones so conversion to // local DateTimes from UTC does not work. This extension method fixes that. // https://github.com/jsakamoto/Toolbelt.Blazor.TimeZoneKit/ host.UseLocalTimeZone(); return(host); }
public static WebAssemblyHost AddStaticAssets(this WebAssemblyHost host) { var service = host.Services.GetService <IHeadManager>(); service?.ApplyLink("_content/Leeax.Web.Components/bootstrap.min.css", "stylesheet"); service?.ApplyLink("_content/Leeax.Web.Components/global.min.css", "stylesheet"); return(host); }
public static void Main() { WebAssemblyHostBuilder builder = WebAssemblyHostBuilder.CreateDefault(); WebAssemblyHost host = builder.Build(); jsRuntime = (IJSRuntime)host.Services.GetService(typeof(IJSRuntime)); loadedReferences = GetReferences(builder.HostEnvironment.BaseAddress); loadedReferences.GetAwaiter().OnCompleted(notifyJS);
public static void InitializeBlazoredLocalization(this WebAssemblyHost app) { var jsRuntime = app.Services.GetService(typeof(IJSRuntime)); var browserLocale = ((IJSInProcessRuntime)jsRuntime).Invoke <string>("blazoredLocalisation.getBrowserLocale"); var culture = new CultureInfo(browserLocale); CultureInfo.DefaultThreadCurrentCulture = culture; CultureInfo.DefaultThreadCurrentUICulture = culture; }
public static void SetDefaultCulture(this WebAssemblyHost host) { var jsInterop = (IJSInProcessRuntime)host.Services.GetRequiredService <IJSRuntime>(); var result = jsInterop.Invoke <string>("blazorCulture.get"); var culture = result != null ? new CultureInfo(result) : new CultureInfo("en-US"); CultureInfo.DefaultThreadCurrentCulture = culture; CultureInfo.DefaultThreadCurrentUICulture = culture; }
// based on https://github.com/pranavkm/LocSample private static async Task GetCultureAsync(WebAssemblyHost host) { var jsRuntime = host.Services.GetRequiredService <IJSRuntime>(); var cultureName = await jsRuntime.InvokeAsync <string>("$.blazorCulture.get") ?? CultureInfo.CurrentCulture.Name; var culture = new CultureInfo(cultureName); CultureInfo.DefaultThreadCurrentCulture = culture; CultureInfo.DefaultThreadCurrentUICulture = culture; }
public static async Task Main(string[] args) { WebAssemblyHost webAssemblyHost = CreateWebHost(args); ApplicationData.ServiceProvider = webAssemblyHost.Services; await InitHttpManage(); ConsoleHelperBase.StartWrite(); await webAssemblyHost.RunAsync(); }
private static async Task InitializeServicesAsync(WebAssemblyHost host) { var repositoryService = host.Services.GetRequiredService <IPageRepository>(); (repositoryService as GithubRepositoryService)?.Initialize( "https://raw.githubusercontent.com/mauragas/mauragas.github.io/md-pages/", "pages.json"); var contentHandler = host.Services.GetRequiredService <IContentCache>() as ContentCacheService; await contentHandler.InitializeAsync().ConfigureAwait(false); }
public static async Task InitializeClient(this WebAssemblyHost host, string baseAddress) { host.Services.GetRequiredService <IApplicationHostEnvironment>(); await host.Services.GetRequiredService <ILanguageManagerService>().InitializeLanguage(); await host.Services.GetRequiredService <LocalLoginService>().InitializeLogin(); await host.Services.GetRequiredService <IScrollService>().InitializeScroll(); host.Services.GetRequiredService <HttpClient>().BaseAddress = new Uri(baseAddress); }
public async static Task SetDefaultCulture(this WebAssemblyHost host) { var localStorageService = host.Services.GetRequiredService <ILocalStorageService>(); var culture = (await localStorageService.GetStringAsync(AppConstants.LocalStorageConstants.BlazorCulture)) ?? host.Services.GetRequiredService <IOptions <CulturesConfiguration> >().Value.DefaultCulture; var cultureInfo = new CultureInfo(culture); CultureInfo.DefaultThreadCurrentCulture = cultureInfo; CultureInfo.DefaultThreadCurrentUICulture = cultureInfo; }
private static void ConfigureCulture(WebAssemblyHost host) { var uri = new Uri(host.Services.GetService <NavigationManager>().Uri); var cultureName = HttpUtility.ParseQueryString(uri.Query)["dotNetCulture"] ?? HttpUtility.ParseQueryString(uri.Query)["culture"]; var culture = new CultureInfo(cultureName); CultureInfo.DefaultThreadCurrentCulture = culture; CultureInfo.DefaultThreadCurrentUICulture = culture; }
public static async Task SetDefaultCulture(this WebAssemblyHost host) { var blazorCulture = host.Services.GetRequiredService <BlazorCulture>(); var result = await blazorCulture.GetBlazorCulture(); var culture = result != null ? new CultureInfo(result) : new CultureInfo("en-US"); CultureInfo.DefaultThreadCurrentCulture = culture; CultureInfo.DefaultThreadCurrentUICulture = culture; }
/// <summary> /// 创建WebHost /// </summary> /// <param name="args"></param> /// <returns></returns> private static WebAssemblyHost CreateWebHost(string[] args) { var webAssemblyHostBuilder = WebAssemblyHostBuilder.CreateDefault(args); WebAPPConfig.SetConfiguration(webAssemblyHostBuilder.Configuration); webAssemblyHostBuilder.RootComponents.Add <App>("app"); webAssemblyHostBuilder.Services.AddWebAPPServices(); WebAssemblyHost webAssemblyHost = webAssemblyHostBuilder.Build(); return(webAssemblyHost); }
private static async Task SetBrowserCulture(WebAssemblyHost host) { var jsInterop = host.Services.GetRequiredService <IJSRuntime>(); var result = await jsInterop.InvokeAsync <string>("blazorCulture.get"); if (result != null) { var culture = new CultureInfo(result); CultureInfo.DefaultThreadCurrentCulture = culture; CultureInfo.DefaultThreadCurrentUICulture = culture; } }
public static async Task Main(string[] args) { var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.RootComponents.Add <App>("app"); ConfigureServices(builder.Services, builder); WebAssemblyHost host = builder.Build(); await host.RunAsync(); }