From 82594cff3427542ac7831aefa453bb4fa493043d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20Ko=C5=BEelj?= Date: Tue, 6 Dec 2022 19:16:52 +0100 Subject: [PATCH] Remove connected specific files --- Instance.cs | 63 ----------------------------------------------------- Routes.cs | 6 ----- 2 files changed, 69 deletions(-) delete mode 100644 Instance.cs delete mode 100644 Routes.cs diff --git a/Instance.cs b/Instance.cs deleted file mode 100644 index 19a273b..0000000 --- a/Instance.cs +++ /dev/null @@ -1,63 +0,0 @@ -using Connected.Middleware; -using Connected.Startup; -using Microsoft.AspNetCore.Components; -using Microsoft.AspNetCore.Components.Web; -using Microsoft.AspNetCore.Components.WebAssembly.Hosting; -using Microsoft.Extensions.DependencyInjection; - -namespace Connected; - -public static class Instance -{ - public static WebAssemblyHost Host { get; private set; } = default!; - private static IServiceProvider ServiceProvider { get; set; } = default!; - - internal static T? GetService() - { - return ServiceProvider.GetService(); - } - public static async Task Start(List startups, Dictionary args) where TApp : IComponent - { - var builder = WebAssemblyHostBuilder.CreateDefault(UnpackArguments(args)); - - builder.RootComponents.Add("#app"); - builder.RootComponents.Add("head::after"); - - builder.Services.AddHttpClient(); - - builder.Services.AddSingleton(typeof(IComponentMiddlewareService), typeof(ComponentMiddlewareService)); - builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); - - foreach (var startup in startups) - await startup.ConfigureServices(builder.Services); - - Host = builder.Build(); - - foreach (var startup in startups) - await startup.Configure(Host); - - await Host.RunAsync(); - } - - private static string[] UnpackArguments(Dictionary args) - { - var result = new string[args.Count]; - - for (var i = 0; i < args.Count; i++) - { - var arg = args.ElementAt(i); - - result[i] = string.IsNullOrWhiteSpace(arg.Value) ? arg.Key : $"{arg.Key}={arg.Value}"; - } - - return result; - } - - public static void UseMiddlewareComponent(this WebAssemblyHost app) - { - if (app.Services.GetService() is not IComponentMiddlewareService service) - throw new NullReferenceException(nameof(IComponentMiddlewareService)); - - service.Add(); - } -} diff --git a/Routes.cs b/Routes.cs deleted file mode 100644 index 65ca957..0000000 --- a/Routes.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Connected; - -public static class UIRoutes -{ - public const string Management = "management"; -}