public static async Task Main(string[] args) { var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.RootComponents.Add <App>("#app"); builder.Services.Configure <BrotliCompressionProviderOptions>(options => { options.Level = CompressionLevel.NoCompression; }); builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); builder.Services.AddTelerikBlazor(); await builder.Build().RunAsync(); }
public static async Task Main(string[] args) { var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.Services.AddScoped <AuthenticationService>(s => new AuthenticationService(URL)); builder.Services.AddBlazoredLocalStorage(); builder.Services.AddOptions(); builder.Services.AddAuthorizationCore(); builder.Services.AddFileReaderService(options => { options.UseWasmSharedBuffer = true; }); builder.Services.AddScoped <AuthenticationStateProvider, LocalAuthenticationStateProvider>(); builder.Services.AddScoped <DialogService>(); builder.Services.AddScoped <NotificationService>(); builder.RootComponents.Add <App>("app"); await builder.Build().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) }); builder.Services.AddSingleton <ApplicationState>(); builder.Services.AddSingleton <UnicodeVersionRepository>(); builder.Services.AddSingleton <BlockRepository>(); builder.Services.AddSingleton <BlockCodePointRepository>(); builder.Services.AddSingleton <CodePointRepository>(); builder.Services.AddSingleton <DecompositionRepository>(); builder.Services.AddSingleton <SearchRepository>(); await builder.Build().RunAsync(); }
public static async Task Main(string[] args) { var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.RootComponents.Add <App>("app"); var httpClient = new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }; builder.Services.AddScoped(sp => httpClient); var siteSettings = await httpClient.GetFromJsonAsync <SettingsModel>("settings.json") .ConfigureAwait(false); builder.Services.AddSingleton <BlogBasicsModel>(siteSettings.BlogBasics); await builder.Build().RunAsync(); }
public static async Task Main(string[] args) { var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.RootComponents.Add <App>("app"); builder.Services.AddTransient(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); var host = builder.Build(); var jsRuntime = host.Services.GetRequiredService <IJSRuntime>(); var prop = typeof(JSRuntime).GetProperty("JsonSerializerOptions", BindingFlags.NonPublic | BindingFlags.Instance); JsonSerializerOptions value = (JsonSerializerOptions)Convert.ChangeType(prop.GetValue(jsRuntime, null), typeof(JsonSerializerOptions)); value.IgnoreNullValues = true; await builder.Build().RunAsync(); }
public static async Task Main(string[] args) { var builder = WebAssemblyHostBuilder.CreateDefault(args); if (builder.HostEnvironment.BaseAddress == "https://localhost:44313/") { builder.RootComponents.Add <App>("#app"); } builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); builder.Services.AddScoped <Api.ITradeLikeVotesClient>(sp => new Api.TradeLikeVotesClient(builder.HostEnvironment.BaseAddress, new HttpClient())); builder.Services.AddScoped <Api.IDonateLikeVotesClient>(sp => new Api.DonateLikeVotesClient(builder.HostEnvironment.BaseAddress, new HttpClient())); builder.Services.AddScoped <Api.IVenderLikeVotesClient>(sp => new Api.VenderLikeVotesClient(builder.HostEnvironment.BaseAddress, new HttpClient())); await builder.Build().RunAsync(); }
public static async Task Main(string[] args) { var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.RootComponents.Add <App>("#app"); builder.Services.AddHttpClient("ClipShare.ServerAPI", client => client.BaseAddress = new Uri(builder.HostEnvironment.BaseAddress)) .AddHttpMessageHandler <BaseAddressAuthorizationMessageHandler>(); // Supply HttpClient instances that include access tokens when making requests to the server project builder.Services.AddScoped(sp => sp.GetRequiredService <IHttpClientFactory>().CreateClient("ClipShare.ServerAPI")); builder.Services.AddApiAuthorization(); builder.Services.AddSingleton <IClipboardService, ClipboardService>(); builder.Services.AddSingleton <IToastService, ToastService>(); await builder.Build().RunAsync(); }
public static async Task Main(string[] args) { var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.RootComponents.Add <App>("app"); builder.Services.AddAntDesign(); builder.Services.AddScoped(_ => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); builder.Services.AddSingleton <IAPIProvider, APIWebProvider>(); builder.Services.AddBlazoredLocalStorage(); builder.Services.AddScoped <IStorage, StorageProvider>(); builder.Services.AddScoped <INavigator, Navigator>(); builder.Services.AddScoped <IPagingManager, AntDesignPagingManager>(); builder.Services.AddScoped <AuthenticationStateProvider, ApiAuthenticationStateProvider>(); builder.Services.AddHttpClient <IAPIAuth, APIWebAuth>("ServerClient", client => client.BaseAddress = new Uri("https://localhost:5001")); builder.Services.AddAuthorizationCore(); builder.Services .AddScoped <IBooksViewModel, BooksViewModel>() .AddScoped <IAllPartsViewModel, PartsAllViewModel>() .AddScoped <IPartViewModel, PartViewModel>() .AddScoped <IPartPropertiesViewModel, PartPropertiesViewModel>() .AddScoped <IBookSectionsViewModel, BookSectionsViewModel>() .AddScoped <IBookViewModel, BookViewModel>() .AddScoped <IBookModelsViewModel, BookModelsViewModel>() .AddScoped <ISectionPartsViewModel, SectionPartsViewModel>() .AddScoped <IModelViewModel, ModelViewModel>() .AddScoped <IEngineViewModel, EngineViewModel>(); builder.Services .AddScoped <ILoginViewModel, LoginViewModel>() .AddScoped <IRegisterViewModel, RegisterViewModel>() .AddScoped <IForgotPasswordViewModel, ForgotPasswordViewModel>() .AddScoped <IResetPasswordViewModel, ResetPasswordViewModel>(); builder.Services .AddScoped <ILoginViewModelValidator, LoginValidator>() .AddScoped <IRegisterViewModelValidator, RegisterValidator>() .AddScoped <IForgotPasswordViewModelValidator, ForgotPasswordValidator>() .AddScoped <IResetPasswordViewModelValidator, ResetPasswordValidator>(); // ReSharper disable once AsyncConverter.AsyncAwaitMayBeElidedHighlighting await builder.Build().RunAsync().ConfigureAwait(false); }
public static async Task Main(string[] args) { var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.RootComponents.Add <App>("app"); builder.Services.AddHttpClient( "ChatClient", c => { c.BaseAddress = new Uri("https://hotchocolate-chat.azurewebsites.net"); c.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", _token); } ); builder.Services.AddChatClient(); await builder.Build().RunAsync(); }
public static async Task Main(string[] args) { var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.Services.AddOptions(); builder.Services.AddAuthorizationCore(); builder.Services.TryAddSingleton <AuthenticationStateProvider, HostAuthenticationStateProvider>(); builder.Services.TryAddSingleton(sp => (HostAuthenticationStateProvider)sp.GetRequiredService <AuthenticationStateProvider>()); builder.Services.AddTransient <AuthorizedHandler>(); builder.Services.AddHttpClient("default", client => client.BaseAddress = new Uri(builder.HostEnvironment.BaseAddress)); builder.Services.AddHttpClient("authorizedClient") .AddHttpMessageHandler <AuthorizedHandler>(); builder.Services.AddTransient(sp => sp.GetRequiredService <IHttpClientFactory>().CreateClient("default")); builder.Services.AddTransient <FetchWeatherForecastService>(); builder.RootComponents.Add <App>("app"); await builder.Build().RunAsync(); }
public static async Task Main(string[] args) { var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.RootComponents.Add <App>("#app"); builder.Services.AddHttpClient("Bakery.ServerAPI", client => client.BaseAddress = new Uri(builder.HostEnvironment.BaseAddress)) .AddHttpMessageHandler <BaseAddressAuthorizationMessageHandler>(); builder.Services.AddHttpClient("Bakery.ServerAPI.NoAuth", client => client.BaseAddress = new Uri(builder.HostEnvironment.BaseAddress)); builder.Services.AddScoped(sp => sp.GetRequiredService <IHttpClientFactory>().CreateClient("Bakery.ServerAPI")); builder.Services.AddScoped(sp => new NoAuthHttpClient(sp.GetRequiredService <IHttpClientFactory>().CreateClient("Bakery.ServerAPI.NoAuth"))); builder.Services.AddApiAuthorization(); builder.Services.AddSweetAlert2(); await builder.Build().RunAsync(); }
public static async Task Main(string[] args) { var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.RootComponents.Add <App>("app"); builder.Services.AddHttpClient("Occumetric.ServerAPI", client => client.BaseAddress = new Uri(builder.HostEnvironment.BaseAddress)) .AddHttpMessageHandler <BaseAddressAuthorizationMessageHandler>(); // Supply HttpClient instances that include access tokens when making requests to the // server project builder.Services.AddTransient(sp => sp.GetRequiredService <IHttpClientFactory>().CreateClient("Occumetric.ServerAPI")); builder.Services.AddTransient <ICommonHttpService, CommonHttpService>(); builder.Services.AddTransient <IGlobalsService, GlobalsService>(); builder.Services.AddApiAuthorization(); await builder.Build().RunAsync(); }
public static async Task Main(string[] args) { var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.RootComponents.Add <App>("app"); builder.Services.AddLibrame() //.AddEncryption().AddGlobalSigningCredentials() // AddIdentity() Default: AddDeveloperGlobalSigningCredentials() .AddData(dependency => { dependency.Options.IdentifierGenerator = CombIdentifierGenerator.MySQL; // Use MySQL dependency.Options.DefaultTenant.DefaultConnectionString = MySqlConnectionStringHelper.Validate("server=localhost;port=3306;database=librame_content_default;user=root;password=123456;"); dependency.Options.DefaultTenant.WritingConnectionString = MySqlConnectionStringHelper.Validate("server=localhost;port=3306;database=librame_content_writing;user=root;password=123456;"); //dependency.Options.DefaultTenant.WritingSeparation = true; }) .AddAccessor <ContentDbContextAccessor>((tenant, optionsBuilder) => { optionsBuilder.UseMySql(tenant.DefaultConnectionString, mySql => { mySql.MigrationsAssembly(typeof(ContentDbContextAccessor).GetAssemblyDisplayName()); mySql.ServerVersion(new Version(5, 7, 28), ServerType.MySql); }); }) .AddDatabaseDesignTime <MySqlDesignTimeServices>() .AddStoreHub <ContentStoreHub>() .AddStoreIdentifierGenerator <GuidContentStoreIdentificationGenerator>() .AddStoreInitializer <GuidContentStoreInitializer>() .AddContent(dependency => { dependency.Options.Stores.MaxLengthForProperties = 128; }); builder.Services.AddTransient(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); await builder.Build().RunAsync(); }
public static async Task Main(string[] args) { var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.RootComponents.Add <App>("app"); builder.Services.AddHttpClient("BlazorApp4.ServerAPI", client => client.BaseAddress = new Uri(builder.HostEnvironment.BaseAddress)) .AddHttpMessageHandler <BaseAddressAuthorizationMessageHandler>(); // Supply HttpClient instances that include access tokens when making requests to the server project builder.Services.AddTransient(sp => sp.GetRequiredService <IHttpClientFactory>().CreateClient("BlazorApp4.ServerAPI")); builder.Services.AddMsalAuthentication(options => { options.ProviderOptions.AdditionalScopesToConsent.Add("https://graph.microsoft.com/User.Read"); }); builder.Services.AddApiAuthorization(); await builder.Build().RunAsync(); }
public static async Task Main(string[] args) { var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.RootComponents.Add<App>("app"); builder.Services.AddScoped<HttpProcessingDelegatingHandler>(); builder.Services .AddHttpClient("local", c => c.BaseAddress = new Uri(builder.HostEnvironment.BaseAddress)) .AddHttpMessageHandler<HttpProcessingDelegatingHandler>(); builder.Services.AddFluxor(options => options .ScanAssemblies(typeof(Program).Assembly) .UseRouting() .UseReduxDevTools() ); await builder.Build().RunAsync(); }
static async Task<BuildStatus> LoadBuildStatus(WebAssemblyHostBuilder builder, HttpClient client) { if (HasHost) { using var response = await client.GetAsync("/Server/Build"); using var stream = await response.Content.ReadAsStreamAsync(); builder.Configuration.AddJsonStream(stream); } else { using var response = await client.GetAsync("build.json"); response.EnsureSuccessStatusCode(); using var stream = await response.Content.ReadAsStreamAsync(); builder.Configuration.AddJsonStream(stream); } BuildStatus res = new BuildStatus(); builder.Configuration.GetSection("Build").Bind(res); return res; }
/// <summary> /// /// </summary> /// <param name="args"></param> /// <returns></returns> public static async Task Main(string[] args) { var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.RootComponents.Add <App>("app"); builder.Services.AddTransient(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); // 增加 BootstrapBlazor 组件 builder.Services.AddBootstrapBlazor(); builder.Services.AddSingleton <WeatherForecastService>(); var host = builder.Build(); await host.RunAsync(); }
public static async Task Main(string[] args) { var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.RootComponents.Add <App>("app"); builder.Logging.SetMinimumLevel(LogLevel.Information); builder.Services.AddScoped( sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); builder.Services.AddSingleton( sp => new WindowState()); builder.Services.AddSingleton <IDialogService, DialogService>(); await builder.Build().RunAsync(); }
public static async Task Main(string[] args) { var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.RootComponents.Add <App>("#app"); builder.Services.AddHttpClient("ServerAPI", client => client.BaseAddress = new Uri(builder.HostEnvironment.BaseAddress)) .AddHttpMessageHandler <BaseAddressAuthorizationMessageHandler>(); builder.Services.AddScoped(sp => sp.GetRequiredService <IHttpClientFactory>().CreateClient("ServerAPI")); //builder.Services.AddOidcAuthentication(options => builder.Configuration.Bind("oidc", options.ProviderOptions)); builder.Services.AddOidcAuthentication(opt => { opt.ProviderOptions.Authority = "https://localhost"; opt.ProviderOptions.ClientId = "blazor_app"; opt.ProviderOptions.ResponseType = "code"; opt.ProviderOptions.PostLogoutRedirectUri = "https://localhost/authentication/logout-callback"; opt.ProviderOptions.RedirectUri = "https://localhost/authentication/login-callback"; }); await builder.Build().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) }); builder.Services.AddOidcAuthentication(options => { // Configure your authentication provider options here. // For more information, see https://aka.ms/blazor-standalone-auth builder.Configuration.Bind("Local", options.ProviderOptions); }); await builder.Build().RunAsync(); }
public static async Task Main(string[] args) { var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.RootComponents.Add <App>("app"); builder.Services.AddTransient(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); builder.Services.AddFileReaderService(options => options.InitializeOnFirstCall = true); // Radzen builder.Services.AddScoped <DialogService>(); builder.Services.AddScoped <NotificationService>(); // Store builder.Services.AddScoped <OrderStateProvider>(); // HTTP Service builder.Services.AddScoped <IHttpService, HttpService>(); // Repositories builder.Services.AddScoped <IUserClient, UserClient>(); builder.Services.AddScoped <IProductClient, ProductClient>(); builder.Services.AddScoped <IOrderClient, OrderClient>(); builder.Services.AddScoped <ICategoryClient, CategoryClient>(); // Helpers builder.Services.AddScoped <IDisplayToast, DisplayToast>(); // Authorization builder.Services.AddOptions(); builder.Services.AddAuthorizationCore(); // Authentication builder.Services.AddScoped <JwtAuthenticationStateProvider>(); builder.Services.AddScoped <AuthenticationStateProvider, JwtAuthenticationStateProvider>( provider => provider.GetRequiredService <JwtAuthenticationStateProvider>()); builder.Services.AddScoped <ILoginService, JwtAuthenticationStateProvider>( provider => provider.GetRequiredService <JwtAuthenticationStateProvider>()); await builder.Build().RunAsync(); }
public static async Task Main(string[] args) { var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.RootComponents.Add <App>("app"); builder.Services.AddStorage(); builder.Services.AddScoped <TokenStorage>(); builder.Services.AddScoped <AccountService>(); builder.Services.AddScoped <TokenAuthenticationStateProvider>(); builder.Services.AddScoped <AuthenticationStateProvider>(provider => provider.GetRequiredService <TokenAuthenticationStateProvider>()); builder.Services.AddAuthorizationCore(); builder.Services.AddOptions(); await builder.Build().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) }); var settings = await LoadSettingsFromHostAsync(builder.Services); builder.Services.AddSingleton(settings); builder.Services.AddTransient <ApiAuthorizationMessageHandler>(); builder.Services.AddHttpClient <CatalogClient>( client => client.BaseAddress = new Uri(settings.ApiGatewayUrlExternal)); builder.Services.AddHttpClient <BasketClient>( client => client.BaseAddress = new Uri(settings.ApiGatewayUrlExternal)) .AddHttpMessageHandler <ApiAuthorizationMessageHandler>(); builder.Services.AddHttpClient <OrderClient>( client => client.BaseAddress = new Uri(settings.ApiGatewayUrlExternal)) .AddHttpMessageHandler <ApiAuthorizationMessageHandler>(); builder.Services .AddBlazoredToast() .AddScoped <UserBasket>(); builder.Services.AddOidcAuthentication(options => { builder.Configuration.Bind("OidcAuthentication", options.ProviderOptions); options.ProviderOptions.Authority = settings.IdentityUrlExternal; options.AuthenticationPaths.LogOutSucceededPath = ""; }); var host = builder.Build(); await host.RunAsync(); }
public static async Task Main(string[] args) { GrpcChannel channel = null; CancellationTokenSource cts = new CancellationTokenSource(); var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.RootComponents.Add <App>("app"); builder.Services.AddSingleton <IDialogService, DialogServiceImplementation>(); builder.Services.AddSingleton <IDialogServiceExt>(services => services.GetService <IDialogService>() as DialogServiceImplementation); builder.Services.AddSingleton <IWebSocketHandler, ClientWebSocketHandler>(); builder.Services.AddSingleton(services => { var httpHandler = new GrpcWebHandler(GrpcWebMode.GrpcWebText, new HttpClientHandler()); channel = GrpcChannel.ForAddress("http://localhost:50080/", new GrpcChannelOptions { HttpHandler = httpHandler }); return(new AdminAccess.AdminAccessClient(channel)); }); builder.Services.AddTransient <IMainViewModel, MainViewModel>(); builder.Services.AddTransient <CreateUserViewModel>(); builder.Services.AddTransient <UsersListViewModel>(); builder.Services.AddTransient <QueueViewModel>(); builder.Services.AddTransient <ItemsViewModel>(); await using WebAssemblyHost host = builder.Build(); _ = (host.Services.GetService <IWebSocketHandler>() as ClientWebSocketHandler).RunAsync(cts.Token); await host.RunAsync(); await channel?.ShutdownAsync(); cts.Cancel(); }
//public static HttpClient HttpClient { get; set; } public static async Task Main(string[] args) { var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.RootComponents.Add <App>("app"); builder.Services.AddApiAuthorization(); builder.Services.AddFileReaderService(options => options.UseWasmSharedBuffer = true); builder.Services.AddBlazoredToast(); builder.Services.AddSingleton <BlazorClientState>(); builder.Services.AddSingleton <IBlazorClientConfiguration, BlazorClientConfiguration>(); builder.Services.AddSingleton <IServiceProvider>(builder.Services.BuildServiceProvider()); //todo: local compile //services.AddSingleton<ICSharpCompiler, CSharpCompiler>(); builder.Services.AddSingleton <CSharpRemoteCompiler, CSharpRemoteCompiler>(); builder.Services.AddTransient <CSharpOptimizer, CSharpOptimizer>(); builder.Services.AddTransient <CSharpThreadedOptimizer, CSharpThreadedOptimizer>(); builder.Services.AddTransient <JavascriptOptimizer, JavascriptOptimizer>(); builder.Services.AddSingleton <IMscorlibProvider, MscorlibRemoteProvider>(); builder.Services.AddSingleton <IWorkerFactory, WorkerFactory>(); builder.Services.AddTransient <IPlotlyLineSplitter, PlotlyLineSplitter>(); builder.Services.AddTransient <IPlotlyBinder, PlotlyThreadedBinder>(); builder.Services.AddSingleton <IPlotlyLineSplitterBackgroundWrapper, PlotlyLineSplitterBackgroundWrapper>(); builder.Services.AddTransient(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); JsonSerializer.SetDefaultResolver(StandardResolver.ExcludeNullCamelCase); builder.Services.AddWorkerFactory(); #if !DEBUG builder.Services.Configure <IISServerOptions>(options => { options.AutomaticAuthentication = false; }); #endif await builder.Build().RunAsync(); }
public static async Task Main(string[] args) { var builder = WebAssemblyHostBuilder.CreateDefault(args); //WebAssemblyHttpMessageHandlerOptions.DefaultCredentials = FetchCredentialsOption.Include; builder.RootComponents.Add <App>("app"); //builder.Services.AddBaseAddressHttpClient(); builder.Services.AddTransient(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); builder.Services.AddTransient(sp => new HttpClientHandler() { UseCookies = true, UseDefaultCredentials = true }); builder.Services.AddAuthorizationCore(); builder.Services.AddScoped <IdentityAuthenticationStateProvider>(); builder.Services.AddScoped <AuthenticationStateProvider>(s => s.GetRequiredService <IdentityAuthenticationStateProvider>()); builder.Services.AddScoped <IAuthorizeApi, AuthorizeApi>(); builder.Services.AddScoped <WebApiServices>(); builder.Services.AddLoadingBar(); builder.Services.AddMatToaster(config => { config.Position = MatToastPosition.BottomRight; config.PreventDuplicates = true; config.NewestOnTop = true; config.ShowCloseButton = true; config.MaximumOpacity = 95; config.VisibleStateDuration = 3000; }); await builder.Build().RunAsync(); }
public static async Task Main(string[] args) { var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.RootComponents.Add <App>("app"); builder.Services.AddTransient(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); builder.Services.AddApiAuthorization(); builder.Services.AddScoped <AuthenticationStateProvider, ServerAuthenticationStateProvider>(); // services builder.Services.AddSingleton <AppState>(); // custom validators builder.Services.AddScoped <RefuelEntryValidator>(); builder.Services.AddScoped <CarValidator>(); builder.Services.AddScoped <ImportValidator>(); builder.Services.AddScoped <JoinGroupValidator>(); builder.Services.AddScoped <AddGroupValidator>(); builder.Services.AddScoped <ServiceEntryValidator>(); // blazorize builder.Services .AddBlazorise(options => { options.ChangeTextOnKeyPress = true; }) .AddBootstrapProviders() .AddFontAwesomeIcons(); var host = builder.Build(); host.Services .UseBootstrapProviders() .UseFontAwesomeIcons(); await host.RunAsync(); }
public static async Task Main(string[] args) { var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.Services .AddBlazorise(options => { options.ChangeTextOnKeyPress = true; }) .AddMaterialProviders() .AddMaterialIcons(); builder.RootComponents.Add <App>("app"); builder.Services.AddTransient(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); builder.Services.AddSingleton <FetchDataViewModel>(); builder.Services.AddSingleton <IIdGenerator <long> >(_ => new IdGenerator(0)); builder.Services.AddScoped <Func <Node <ToDo, long>, ToDoViewModel> >(c => node => new ToDoViewModel(node, c.GetRequiredService <TodoServiceFacade>(), c.GetRequiredService <IMapper>())); builder.Services.AddTransient <ToDosViewModel>(); builder.Services.AddScoped <TodoService>(); builder.Services.AddScoped <TodoSortingService>(); builder.Services.AddScoped <TodoServiceFacade>(); builder.Services.AddScoped <DragAndDropContainer>(); builder.Services.AddBlazoredLocalStorage(); builder.Services.AddSingleton(new MapperConfiguration(c => { c.AllowNullCollections = true; c.AllowNullDestinationValues = true; c.AddProfile <Mapping>(); }).CreateMapper()); var host = builder.Build(); host.Services .UseMaterialProviders() .UseMaterialIcons(); await host.RunAsync(); }
public static async Task Main(string[] args) { var builder = WebAssemblyHostBuilder.CreateDefault(); builder.RootComponents.Add <App>("app"); var host = builder.Build(); builder.Services.AddSingleton <IOC>(new IOC(builder.Services)); Xamarin.Essentials.Blazor.GoogleHttpGeocoding.APIKey = Core.Helpers.Keys.GoogleGeocodingKey; builder.Services.AddScoped <IGeocoding, Xamarin.Essentials.Blazor.GoogleHttpGeocoding>(); var nav = new NavigationService(builder.Services); builder.Services.AddSingleton <INavigationService>(nav); //Register pages for navigation nav.Register(typeof(BusinessDetailsViewModel), "businessdetails"); nav.Register(typeof(BusinessViewModel), "businesses"); nav.Register(typeof(HomeViewModel), "/"); var provider = builder.Services.BuildServiceProvider(); Debug.WriteLine($"Provider built "); IOC.Current.Provider = provider; foreach (var service in builder.Services) { Debug.WriteLine($"service: {service.ImplementationInstance} {service.ImplementationType} {service.Lifetime}"); } Debug.WriteLine($"services loaded"); var na = provider.GetService <INavigationService>(); Debug.WriteLine($"nav: {na}"); await host.RunAsync(); }
public static async Task Main(string[] args) { var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.RootComponents.Add <App>("app"); //builder.Services.AddSingleton<IApiSettings>(builder.Configuration.GetSection(nameof(ApiSettings)).Get<ApiSettings>()); builder.Services.AddSingleton(sp => builder.Configuration.GetSection(nameof(ApiSettings)).Get <ApiSettings>()); //builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); //builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.Configuration["ApiSettings:BaseUrl"]) }); builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(sp.GetRequiredService <ApiSettings>().BaseUrl) }); //builder.Services.AddSingleton<LocationService>(); //builder.Services.AddScoped<LocationService>(); await builder.Build().RunAsync(); }