1- using Microsoft . AspNetCore . Components . WebAssembly . Hosting ;
2- using Microsoft . Extensions . Configuration ;
3- using Microsoft . Extensions . DependencyInjection ;
4- using Microsoft . Extensions . Logging ;
51using System ;
6- using System . Collections . Generic ;
72using System . Net . Http ;
83using System . Net . Http . Json ;
9- using System . Text ;
104using System . Threading . Tasks ;
5+ using Microsoft . AspNetCore . Components . WebAssembly . Hosting ;
6+ using Microsoft . Extensions . DependencyInjection ;
117using MudBlazor ;
128using MudBlazor . Services ;
139using OpenCodeFoundation . ESchool . Web . Frontend . Blazor . Shared ;
1410
1511namespace OpenCodeFoundation . ESchool . Web . Frontend . Blazor . Client
1612{
17- public class Program
13+ public static class Program
1814 {
1915 public static async Task Main ( string [ ] args )
2016 {
2117 var builder = WebAssemblyHostBuilder . CreateDefault ( args ) ;
2218 builder . RootComponents . Add < App > ( "#app" ) ;
2319
24- var settings = await LoadFrontendSettings ( builder ) ;
20+ var settings = await LoadFrontendSettings ( builder )
21+ . ConfigureAwait ( false ) ;
2522 builder . Services . AddSingleton ( settings ) ;
2623
2724 builder . Services . AddHttpClient ( "EschoolClient" , client =>
@@ -30,35 +27,34 @@ public static async Task Main(string[] args)
3027 } ) ;
3128 builder . Services . AddEschoolClient ( ) ;
3229
33- builder . Services . AddScoped ( sp => new HttpClient { BaseAddress = new Uri ( builder . HostEnvironment . BaseAddress ) } ) ;
30+ builder . Services . AddScoped ( _ =>
31+ new HttpClient
32+ {
33+ BaseAddress = new Uri ( builder . HostEnvironment . BaseAddress ) ,
34+ } ) ;
3435
35- builder . Services . AddMudBlazorDialog ( ) ;
36- builder . Services . AddMudBlazorSnackbar ( config =>
36+ builder . Services . AddMudServices ( config =>
3737 {
38- config . PositionClass = Defaults . Classes . Position . BottomRight ;
39- config . SnackbarVariant = Variant . Filled ;
38+ config . SnackbarConfiguration . PositionClass = Defaults . Classes . Position . BottomRight ;
39+ config . SnackbarConfiguration . SnackbarVariant = Variant . Filled ;
4040 } ) ;
41- builder . Services . AddMudBlazorResizeListener ( ) ;
4241
43- await builder . Build ( ) . RunAsync ( ) ;
42+ await builder . Build ( ) . RunAsync ( ) . ConfigureAwait ( false ) ;
4443 }
4544
4645 private static async Task < FrontendSettings > LoadFrontendSettings ( WebAssemblyHostBuilder builder )
4746 {
4847 using var http = new HttpClient ( )
4948 {
50- BaseAddress = new Uri ( builder . HostEnvironment . BaseAddress )
49+ BaseAddress = new Uri ( builder . HostEnvironment . BaseAddress ) ,
5150 } ;
5251
5352 var settings = await http
54- . GetFromJsonAsync < FrontendSettings > ( "appsettings" ) ;
55-
56- if ( settings is null )
57- {
58- throw new ArgumentNullException ( nameof ( settings ) ) ;
59- }
53+ . GetFromJsonAsync < FrontendSettings > ( "appsettings" )
54+ . ConfigureAwait ( false ) ;
6055
61- return settings ;
56+ return settings ?? throw new InvalidOperationException (
57+ "Failed to load settings" ) ;
6258 }
6359 }
6460}
0 commit comments