|
1 | | -using Serilog.Core; |
2 | | -using Serilog.Events; |
3 | | -using Serilog; |
4 | | -using TELBlazor.Components.Core.Configuration; |
5 | | -using TELBlazor.Components.Core.Services.HelperServices; |
6 | | -using TELBlazor.Components.ShowCase.E2ETests.WasmServerHost; |
7 | | -using TELBlazor.Components.ShowCase.Shared.Services.HelperServices; |
8 | | - |
9 | | -using Microsoft.Extensions.Http; |
10 | | - |
11 | | - |
| 1 | +// Microsoft namespaces |
| 2 | +using Microsoft.AspNetCore.Components; |
12 | 3 | using Microsoft.AspNetCore.Components.Web; |
13 | 4 | using Microsoft.AspNetCore.Components.WebAssembly.Hosting; |
14 | | -using Microsoft.Extensions.Options; |
15 | 5 | using Microsoft.Extensions.DependencyInjection; |
16 | | -/*Are used via appsetting*/ |
17 | | -using Serilog.Extensions.Logging; |
18 | | -using Serilog.Configuration; |
| 6 | +using Microsoft.Extensions.Http; |
19 | 7 | using Microsoft.Extensions.Logging; |
20 | | -using Microsoft.Extensions.DependencyInjection; |
21 | | -using Serilog.Sinks.BrowserConsole; |
| 8 | +using Microsoft.Extensions.Options; |
| 9 | + |
| 10 | +// Serilog core (used via appsettings, do not delete even if vs marks not in use) |
| 11 | +using Serilog; |
| 12 | +using Serilog.Configuration; |
| 13 | +using Serilog.Core; |
| 14 | +using Serilog.Events; |
| 15 | + |
| 16 | +// Serilog extensions and sinks (used via appsettings, do not delete even if vs marks not in use) |
| 17 | +using Serilog.Extensions.Logging; |
22 | 18 | using Serilog.Formatting.Compact; |
23 | 19 | using Serilog.Settings.Configuration; |
24 | | -using Microsoft.AspNetCore.Components; |
25 | | -/*qqqq setup*/ |
| 20 | +using Serilog.Sinks.BrowserConsole; |
| 21 | + |
| 22 | +// Still required server side even if not used so components dont fail |
26 | 23 | using Blazored.LocalStorage; |
27 | 24 |
|
| 25 | +// TELBlazor components |
| 26 | +using TELBlazor.Components.Core.Configuration; |
| 27 | +using TELBlazor.Components.Core.Services.HelperServices; |
| 28 | +using TELBlazor.Components.ShowCase.E2ETests.WasmServerHost; |
| 29 | +using TELBlazor.Components.ShowCase.Shared.Services.HelperServices; |
28 | 30 |
|
29 | 31 | var builder = WebApplication.CreateBuilder(args); |
30 | 32 |
|
|
57 | 59 | // Add services to the container. |
58 | 60 | builder.Services.AddRazorComponents() |
59 | 61 | .AddInteractiveWebAssemblyComponents(); |
60 | | - //qqqq for di? |
61 | | - builder.Services.AddBlazoredLocalStorage(); |
62 | | - |
63 | | - //qqqq cant remember what for |
64 | | - //builder.Services.AddHttpContextAccessor(); |
65 | | - //builder.Services.AddSession(options => |
66 | | - //{ |
67 | 62 |
|
68 | | - // options.IdleTimeout = TimeSpan.FromMinutes(20); // Set the timeout for the session |
69 | | - // options.Cookie.HttpOnly = true; // Session cookie is only accessible via HTTP |
70 | | - // options.Cookie.IsEssential = true; // Session cookie is essential for application |
71 | | - //}); |
| 63 | + // Future candidates for DI collection |
| 64 | + builder.Services.AddBlazoredLocalStorage(); |
72 | 65 |
|
73 | 66 | builder.Services.AddSingleton<ITELBlazorBaseComponentConfiguration>(provider => |
74 | 67 | { |
75 | | - // qqqq cant rmeember purpose |
76 | | - //In here we would get our appsettings etc and configure - but then we have an object to pass it |
77 | | - //var httpContextAccessor = provider.GetRequiredService<IHttpContextAccessor>(); |
78 | | - ////For this to work well for blazor pages as well we would probably want to set up session storage (which takes js anyway to set up and most blazor application use it i presume) |
79 | | - //var session = httpContextAccessor.HttpContext?.Session; |
80 | | - |
81 | | - |
82 | 68 | return new TELBlazorBaseComponentConfiguration |
83 | 69 | { |
84 | 70 | JSEnabled = true, //if we are inject the client then it is true |
85 | 71 | HostType = $"{builder.Configuration["Properties:Environment"]} {builder.Configuration["Properties:Application"]}" |
86 | 72 | }; |
87 | 73 | }); |
| 74 | + |
88 | 75 | //Scoped because being consumed with storage where singleton doesnt survive mvc page teardown |
89 | 76 | builder.Services.AddScoped<LoggingLevelSwitch>(sp => levelSwitch); |
90 | 77 | builder.Services.AddScoped<ILogLevelSwitcherService, SerilogLogLevelSwitcherService>(); |
| 78 | + |
| 79 | + |
91 | 80 | var app = builder.Build(); |
92 | | - app.UseSerilogRequestLogging(); |
| 81 | + // This is less blazor more endpoint logging |
| 82 | + //app.UseSerilogRequestLogging(); |
| 83 | + |
93 | 84 | // Configure the HTTP request pipeline. |
94 | 85 | if (app.Environment.IsDevelopment()) |
95 | 86 | { |
|
107 | 98 | app.UseStaticFiles(); |
108 | 99 | app.UseAntiforgery(); |
109 | 100 |
|
| 101 | + //We want everything from the blazor project so we add by assembly and put all using statements in the imports |
110 | 102 | app.MapRazorComponents<App>() |
111 | 103 | .AddInteractiveWebAssemblyRenderMode() |
112 | 104 | .AddAdditionalAssemblies(typeof(TELBlazor.Components.ShowCase.E2ETests.WasmServerHost.Client._Imports).Assembly) |
|
0 commit comments