1 files changed, 37 insertions, 0 deletions
diff --git a/testFrontend/SafeNSound.Frontend/Program.cs b/testFrontend/SafeNSound.Frontend/Program.cs
index b48b6db..2642a75 100644
--- a/testFrontend/SafeNSound.Frontend/Program.cs
+++ b/testFrontend/SafeNSound.Frontend/Program.cs
@@ -1,11 +1,48 @@
+using System.Net;
+using System.Text.Json;
+using System.Text.Json.Serialization;
+using Blazored.LocalStorage;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using SafeNSound.Frontend;
+using SafeNSound.Sdk;
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
+builder.Services.AddSingleton<SafeNSoundConfiguration>();
+builder.Services.AddSingleton<SafeNSoundAuthentication>();
+
+
+try {
+ builder.Configuration.AddJsonStream(await new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }.GetStreamAsync("/appsettings.json"));
+#if DEBUG
+ builder.Configuration.AddJsonStream(await new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }.GetStreamAsync("/appsettings.Development.json"));
+#endif
+}
+catch (HttpRequestException e) {
+ if (e.StatusCode == HttpStatusCode.NotFound)
+ Console.WriteLine("Could not load appsettings, server returned 404.");
+ else
+ Console.WriteLine("Could not load appsettings: " + e);
+}
+catch (Exception e) {
+ Console.WriteLine("Could not load appsettings: " + e);
+}
+
+builder.Logging.AddConfiguration(
+ builder.Configuration.GetSection("Logging"));
+
+builder.Services.AddBlazoredLocalStorage(config => {
+ config.JsonSerializerOptions.DictionaryKeyPolicy = JsonNamingPolicy.CamelCase;
+ config.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
+ config.JsonSerializerOptions.IgnoreReadOnlyProperties = true;
+ config.JsonSerializerOptions.PropertyNameCaseInsensitive = true;
+ config.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
+ config.JsonSerializerOptions.ReadCommentHandling = JsonCommentHandling.Skip;
+ config.JsonSerializerOptions.WriteIndented = false;
+});
await builder.Build().RunAsync();
\ No newline at end of file
|