Example #1
0
 /// <summary>
 ///     Adds the <see cref="BlazorUI.Client"/> files for the client as well as routing and the SignalR Query Hub.
 /// </summary>
 /// <param name="configure">An instance of <see cref="ConfigureWebApp"/> from Totem.</param>
 /// <returns></returns>
 public static ConfigureWebApp BlazorWebApplication(this ConfigureWebApp configure)
 {
     return(configure.App(app =>
     {
         var environment = app.ApplicationServices
                           .GetRequiredService <IHostEnvironment>();
         if (environment.IsDevelopment())
         {
             app.UseDeveloperExceptionPage();
             app.UseBlazorDebugging();
         }
         app.UseClientSideBlazorFiles <BlazorUI.Client.Startup>();
         app.UseAuthentication();
         app.UseAuthorization();
         app.UseRouting();
         app.UseCors();
         app.UseEndpoints(endpoints =>
         {
             endpoints.MapControllers();
             endpoints.MapRazorPages();
             endpoints.MapBlazorHub();
             // TODO: Extension method in Timeline.SignalR? -- relies on future .NET Standard Support
             endpoints.MapHub <QueryHub>("/hubs/query");
             endpoints.MapDefaultControllerRoute();
             endpoints.MapControllerRoute("Imports", "{controller=Imports}/{action=StartImport}");
             endpoints.MapControllerRoute("ImportTest", "{controller=Imports}/{action=Test}");
             endpoints.MapFallbackToClientSideBlazor <BlazorUI.Client.Startup>("index.html");
         });
     }));
 }
Example #2
0
 public static ConfigureWebApp EncryptionServices(this ConfigureWebApp configure)
 {
     return(configure.Services((context, services) =>
     {
         //services.AddHostedService(er => new EncryptionReader(new DataProtection()));
     }));
 }
Example #3
0
        public static Task Main()
        {
            var configuration = new ConfigureWebApp();
            var queryMap      = GetTimelineQueryEndpoints();

            return(WebApp.Run <ApplicationArea>(configuration
                                                .BlazorWebApplication()
                                                .ClientUIServices(queryMap)
                                                //EncryptionServices()
                                                .Serilog((context, logger) => {
                logger = new LogConfiguration().VerboseLogger(logger);
            })
                                                ));
        }
Example #4
0
 /// <summary>
 ///     Adds the <see cref="BlazorUI.Client"/> services for the web assembly UI to perform automatic two-way binding.
 /// </summary>
 /// <param name="configure">An instance of a <see cref="ConfigureWebApp"/> from Totem.</param>
 /// <param name="queryMap">A list of <see cref="TimelineRoute"/> which maps a Query type to its <see cref="HttpMethodAttribute"/> route.</param>
 /// <returns></returns>
 public static ConfigureWebApp ClientUIServices(this ConfigureWebApp configure, List <TimelineRoute> queryMap)
 {
     return(configure.Services((context, services) =>
     {
         services.AddServerSideBlazor();
         services.AddSignalR().AddQueryNotifications();
         services.AddTransient <HubConnectionBuilder>();
         services.AddTransient <QueryController>();
         services.AddSingleton <IRouteContext, RouteContext>(sp => new RouteContext(queryMap));
         // Cannot seem to do this type of injection in client-side WASM right now...
         //services.AddTransient<IRouteContextFactory, RouteContextFactory>(sp => new RouteContextFactory(() => sp.GetService<IRouteContext>()));
         services.AddScoped <AppState>(state => new AppState(
                                           state.GetRequiredService <QueryController>(),
                                           state.GetRequiredService <HttpClient>()));
         services.AddHostedService(er => new EncryptionReader(new DataProtection()));
     }));
 }