diff --git a/Apollo.Client/Apollo.Client.csproj b/Apollo.Client/Apollo.Client.csproj index 9d3f724..f9b066b 100644 --- a/Apollo.Client/Apollo.Client.csproj +++ b/Apollo.Client/Apollo.Client.csproj @@ -16,7 +16,7 @@ - + diff --git a/Apollo.Client/Program.cs b/Apollo.Client/Program.cs index 29fc5a6..4389eac 100644 --- a/Apollo.Client/Program.cs +++ b/Apollo.Client/Program.cs @@ -5,12 +5,13 @@ using Apollo.Client.Code; using Apollo.Client.Hosting; using Apollo.Client.Infrastructure; +using Apollo.Components; using Apollo.Components.Analysis; using Apollo.Components.Code; using Apollo.Components.Hosting; using Apollo.Components.Infrastructure; using Apollo.Components.Infrastructure.Environment; -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Infrastructure.Resources; var builder = WebAssemblyHostBuilder.CreateDefault(args); @@ -19,7 +20,7 @@ builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); -builder.Services.AddMessageBus(typeof(Program).Assembly, typeof(IConsumer<>).Assembly); +builder.Services.AddMessageBus(typeof(Program).Assembly, typeof(AppState).Assembly, typeof(IConsumer<>).Assembly); builder.Services.AddSingleton(); @@ -33,6 +34,6 @@ var app = builder.Build(); -app.Services.UseMessageBus(typeof(Program).Assembly, typeof(IConsumer<>).Assembly); +app.Services.UseMessageBus(typeof(Program).Assembly, typeof(AppState).Assembly, typeof(IConsumer<>).Assembly); await app.RunAsync(); \ No newline at end of file diff --git a/Apollo.Client/wwwroot/index.html b/Apollo.Client/wwwroot/index.html index 5808807..73933b3 100644 --- a/Apollo.Client/wwwroot/index.html +++ b/Apollo.Client/wwwroot/index.html @@ -8,7 +8,7 @@ - + diff --git a/Apollo.Components/Analysis/CodeAnalysisState.cs b/Apollo.Components/Analysis/CodeAnalysisState.cs index f4b451c..450fa0f 100644 --- a/Apollo.Components/Analysis/CodeAnalysisState.cs +++ b/Apollo.Components/Analysis/CodeAnalysisState.cs @@ -1,6 +1,6 @@ using System.Text.Json; using Apollo.Components.Console; -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.NuGet; using Apollo.Components.Solutions; using Apollo.Contracts.Analysis; diff --git a/Apollo.Components/Apollo.Components.csproj b/Apollo.Components/Apollo.Components.csproj index c880cbb..0e1dbc1 100644 --- a/Apollo.Components/Apollo.Components.csproj +++ b/Apollo.Components/Apollo.Components.csproj @@ -22,7 +22,7 @@ - + diff --git a/Apollo.Components/Code/ActiveTypeState.cs b/Apollo.Components/Code/ActiveTypeState.cs index da6686d..15e39cc 100644 --- a/Apollo.Components/Code/ActiveTypeState.cs +++ b/Apollo.Components/Code/ActiveTypeState.cs @@ -1,5 +1,5 @@ using System.Reflection; -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Solutions.Events; namespace Apollo.Components.Code; diff --git a/Apollo.Components/Code/CompilerState.cs b/Apollo.Components/Code/CompilerState.cs index 6c2a554..7424da5 100644 --- a/Apollo.Components/Code/CompilerState.cs +++ b/Apollo.Components/Code/CompilerState.cs @@ -3,7 +3,7 @@ using Apollo.Components.Analysis; using Apollo.Components.Console; using Apollo.Components.DynamicTabs.Commands; -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.NuGet; using Apollo.Components.Solutions; using Apollo.Components.Solutions.Events; diff --git a/Apollo.Components/Code/Consumers/ConsoleProjectBuilder.cs b/Apollo.Components/Code/Consumers/ConsoleProjectBuilder.cs index d43729a..4323782 100644 --- a/Apollo.Components/Code/Consumers/ConsoleProjectBuilder.cs +++ b/Apollo.Components/Code/Consumers/ConsoleProjectBuilder.cs @@ -1,5 +1,5 @@ using Apollo.Components.DynamicTabs.Commands; -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Solutions; using Apollo.Components.Solutions.Commands; using Apollo.Contracts.Solutions; diff --git a/Apollo.Components/Code/Consumers/ConsoleRunner.cs b/Apollo.Components/Code/Consumers/ConsoleRunner.cs index 73c81ac..a9931bb 100644 --- a/Apollo.Components/Code/Consumers/ConsoleRunner.cs +++ b/Apollo.Components/Code/Consumers/ConsoleRunner.cs @@ -1,5 +1,5 @@ using Apollo.Components.DynamicTabs.Commands; -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Solutions; using Apollo.Components.Solutions.Commands; using Apollo.Contracts.Solutions; diff --git a/Apollo.Components/Code/Consumers/LibraryProjectBuilder.cs b/Apollo.Components/Code/Consumers/LibraryProjectBuilder.cs index 5ee5303..6afddc1 100644 --- a/Apollo.Components/Code/Consumers/LibraryProjectBuilder.cs +++ b/Apollo.Components/Code/Consumers/LibraryProjectBuilder.cs @@ -1,5 +1,5 @@ using Apollo.Components.DynamicTabs.Commands; -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Solutions; using Apollo.Components.Solutions.Commands; using Apollo.Contracts.Solutions; diff --git a/Apollo.Components/Code/Consumers/LibraryRunner.cs b/Apollo.Components/Code/Consumers/LibraryRunner.cs index 83a0f6d..42e24db 100644 --- a/Apollo.Components/Code/Consumers/LibraryRunner.cs +++ b/Apollo.Components/Code/Consumers/LibraryRunner.cs @@ -1,5 +1,5 @@ using Apollo.Components.DynamicTabs.Commands; -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Solutions; using Apollo.Components.Solutions.Commands; using Apollo.Contracts.Solutions; diff --git a/Apollo.Components/DynamicClient/ClientPreviewTab.razor b/Apollo.Components/DynamicClient/ClientPreviewTab.razor index 38aa7cf..9ec6459 100644 --- a/Apollo.Components/DynamicClient/ClientPreviewTab.razor +++ b/Apollo.Components/DynamicClient/ClientPreviewTab.razor @@ -4,7 +4,7 @@ @using Apollo.Components.DynamicClient.Commands @using Apollo.Components.Hosting @using Apollo.Components.Hosting.Commands -@using Apollo.Components.Infrastructure.MessageBus +@using Mythetech.Framework.Infrastructure.MessageBus @using Apollo.Components.Shared @using Apollo.Components.Solutions @using Apollo.Components.Solutions.Commands diff --git a/Apollo.Components/DynamicClient/Consumers/WebHostClientPreviewer.cs b/Apollo.Components/DynamicClient/Consumers/WebHostClientPreviewer.cs index 2de4f88..99e9cb8 100644 --- a/Apollo.Components/DynamicClient/Consumers/WebHostClientPreviewer.cs +++ b/Apollo.Components/DynamicClient/Consumers/WebHostClientPreviewer.cs @@ -1,7 +1,7 @@ using Apollo.Components.DynamicTabs; using Apollo.Components.DynamicTabs.Commands; using Apollo.Components.Hosting.Events; -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Solutions; namespace Apollo.Components.DynamicClient.Consumers; diff --git a/Apollo.Components/DynamicTabs/Consumers/DockCloser.cs b/Apollo.Components/DynamicTabs/Consumers/DockCloser.cs index 8ad038d..0c21678 100644 --- a/Apollo.Components/DynamicTabs/Consumers/DockCloser.cs +++ b/Apollo.Components/DynamicTabs/Consumers/DockCloser.cs @@ -1,6 +1,6 @@ using Apollo.Components.DynamicTabs.Commands; using Apollo.Components.Editor; -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; namespace Apollo.Components.DynamicTabs.Consumers; diff --git a/Apollo.Components/DynamicTabs/Consumers/DockOpener.cs b/Apollo.Components/DynamicTabs/Consumers/DockOpener.cs index 8c6c587..1864ade 100644 --- a/Apollo.Components/DynamicTabs/Consumers/DockOpener.cs +++ b/Apollo.Components/DynamicTabs/Consumers/DockOpener.cs @@ -1,6 +1,6 @@ using Apollo.Components.DynamicTabs.Commands; using Apollo.Components.Editor; -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; namespace Apollo.Components.DynamicTabs.Consumers; diff --git a/Apollo.Components/DynamicTabs/Consumers/DockedTabHider.cs b/Apollo.Components/DynamicTabs/Consumers/DockedTabHider.cs index ad37d7f..804ca5a 100644 --- a/Apollo.Components/DynamicTabs/Consumers/DockedTabHider.cs +++ b/Apollo.Components/DynamicTabs/Consumers/DockedTabHider.cs @@ -1,6 +1,6 @@ using Apollo.Components.DynamicTabs.Commands; using Apollo.Components.Editor; -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; namespace Apollo.Components.DynamicTabs.Consumers; diff --git a/Apollo.Components/DynamicTabs/Consumers/FloatingWindowCloser.cs b/Apollo.Components/DynamicTabs/Consumers/FloatingWindowCloser.cs index 857f1e0..be869e8 100644 --- a/Apollo.Components/DynamicTabs/Consumers/FloatingWindowCloser.cs +++ b/Apollo.Components/DynamicTabs/Consumers/FloatingWindowCloser.cs @@ -1,6 +1,6 @@ using Apollo.Components.DynamicTabs.Commands; using Apollo.Components.Editor; -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; namespace Apollo.Components.DynamicTabs.Consumers; diff --git a/Apollo.Components/DynamicTabs/Consumers/TabFocuser.cs b/Apollo.Components/DynamicTabs/Consumers/TabFocuser.cs index 14d9ae6..84c0073 100644 --- a/Apollo.Components/DynamicTabs/Consumers/TabFocuser.cs +++ b/Apollo.Components/DynamicTabs/Consumers/TabFocuser.cs @@ -1,6 +1,6 @@ using Apollo.Components.DynamicTabs.Commands; using Apollo.Components.Editor; -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; namespace Apollo.Components.DynamicTabs.Consumers; diff --git a/Apollo.Components/DynamicTabs/Consumers/TabHider.cs b/Apollo.Components/DynamicTabs/Consumers/TabHider.cs index 30bc0aa..bccee02 100644 --- a/Apollo.Components/DynamicTabs/Consumers/TabHider.cs +++ b/Apollo.Components/DynamicTabs/Consumers/TabHider.cs @@ -1,6 +1,6 @@ using Apollo.Components.DynamicTabs.Commands; using Apollo.Components.Editor; -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; namespace Apollo.Components.DynamicTabs.Consumers; diff --git a/Apollo.Components/DynamicTabs/Consumers/TabLocationUpdater.cs b/Apollo.Components/DynamicTabs/Consumers/TabLocationUpdater.cs index fdca264..6568829 100644 --- a/Apollo.Components/DynamicTabs/Consumers/TabLocationUpdater.cs +++ b/Apollo.Components/DynamicTabs/Consumers/TabLocationUpdater.cs @@ -1,6 +1,6 @@ using Apollo.Components.DynamicTabs.Commands; using Apollo.Components.Editor; -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; namespace Apollo.Components.DynamicTabs.Consumers; diff --git a/Apollo.Components/DynamicTabs/TabDropZone.razor b/Apollo.Components/DynamicTabs/TabDropZone.razor index afed85e..a6a22a1 100644 --- a/Apollo.Components/DynamicTabs/TabDropZone.razor +++ b/Apollo.Components/DynamicTabs/TabDropZone.razor @@ -1,7 +1,7 @@ @using Apollo.Components.DynamicTabs.Commands @using Microsoft.JSInterop @using Apollo.Components.Editor -@using Apollo.Components.Infrastructure.MessageBus +@using Mythetech.Framework.Infrastructure.MessageBus @using Apollo.Components.Shared @using Apollo.Components.Theme @inherits Apollo.Components.Infrastructure.ApolloBaseComponent diff --git a/Apollo.Components/DynamicTabs/TabMenu.razor b/Apollo.Components/DynamicTabs/TabMenu.razor index fd8cd46..3f9e3cb 100644 --- a/Apollo.Components/DynamicTabs/TabMenu.razor +++ b/Apollo.Components/DynamicTabs/TabMenu.razor @@ -1,6 +1,6 @@ @using Apollo.Components.DynamicTabs.Commands @using Apollo.Components.Editor -@using Apollo.Components.Infrastructure.MessageBus +@using Mythetech.Framework.Infrastructure.MessageBus @using Apollo.Components.Theme @using Apollo.Components.Shared @using MouseEvent = MudBlazor.MouseEvent diff --git a/Apollo.Components/Editor/ApolloCodeEditor.razor b/Apollo.Components/Editor/ApolloCodeEditor.razor index 9c737aa..b0ce15b 100644 --- a/Apollo.Components/Editor/ApolloCodeEditor.razor +++ b/Apollo.Components/Editor/ApolloCodeEditor.razor @@ -22,7 +22,7 @@ @using Command = BlazorMonaco.Languages.Command @using InsertTextRule = BlazorMonaco.Languages @implements IDisposable -@inherits Apollo.Components.Infrastructure.MessageBus.ComponentConsumer> +@inherits Mythetech.Framework.Infrastructure.MessageBus.ComponentConsumer> diff --git a/Apollo.Components/Editor/ApolloMenu.razor b/Apollo.Components/Editor/ApolloMenu.razor index 6002909..8508072 100644 --- a/Apollo.Components/Editor/ApolloMenu.razor +++ b/Apollo.Components/Editor/ApolloMenu.razor @@ -1,4 +1,4 @@ -@using Apollo.Components.Infrastructure.MessageBus +@using Mythetech.Framework.Infrastructure.MessageBus @using Apollo.Components.Settings @using Apollo.Components.Settings.Commands @using Apollo.Components.Shared diff --git a/Apollo.Components/Editor/EditMenu.razor b/Apollo.Components/Editor/EditMenu.razor index 2e5d516..7eefe67 100644 --- a/Apollo.Components/Editor/EditMenu.razor +++ b/Apollo.Components/Editor/EditMenu.razor @@ -1,4 +1,4 @@ -@using Apollo.Components.Infrastructure.MessageBus +@using Mythetech.Framework.Infrastructure.MessageBus @using Apollo.Components.Solutions.Commands @using Apollo.Components.Solutions.Consumers @using Apollo.Components.Theme diff --git a/Apollo.Components/Editor/FileMenu.razor b/Apollo.Components/Editor/FileMenu.razor index 86e4ada..cfa8c44 100644 --- a/Apollo.Components/Editor/FileMenu.razor +++ b/Apollo.Components/Editor/FileMenu.razor @@ -1,4 +1,4 @@ -@using Apollo.Components.Infrastructure.MessageBus +@using Mythetech.Framework.Infrastructure.MessageBus @using Apollo.Components.Solutions.Commands @using Apollo.Components.Solutions.Consumers @using Apollo.Components.Theme diff --git a/Apollo.Components/Editor/Home.razor b/Apollo.Components/Editor/Home.razor index 7baeb5b..49e02a4 100644 --- a/Apollo.Components/Editor/Home.razor +++ b/Apollo.Components/Editor/Home.razor @@ -13,7 +13,7 @@ @using Apollo.Components.Infrastructure.Keyboard @using KeyCode = Microsoft.FluentUI.AspNetCore.Components.KeyCode @using Apollo.Components.Solutions.Commands -@using Apollo.Components.Infrastructure.MessageBus +@using Mythetech.Framework.Infrastructure.MessageBus @using Apollo.Components.Terminal @using Apollo.Components.DynamicTabs.Commands @using Apollo.Components.Settings.Commands diff --git a/Apollo.Components/Editor/ToolsMenu.razor b/Apollo.Components/Editor/ToolsMenu.razor index d6802fd..0810915 100644 --- a/Apollo.Components/Editor/ToolsMenu.razor +++ b/Apollo.Components/Editor/ToolsMenu.razor @@ -1,4 +1,4 @@ -@using Apollo.Components.Infrastructure.MessageBus +@using Mythetech.Framework.Infrastructure.MessageBus @using Apollo.Components.Infrastructure.Environment @using Apollo.Components.NuGet.Commands @using Apollo.Components.Tools.Commands diff --git a/Apollo.Components/Editor/ViewMenu.razor b/Apollo.Components/Editor/ViewMenu.razor index c0cc0e6..75eef51 100644 --- a/Apollo.Components/Editor/ViewMenu.razor +++ b/Apollo.Components/Editor/ViewMenu.razor @@ -1,6 +1,6 @@ @using Apollo.Components.DynamicTabs @using Apollo.Components.DynamicTabs.Commands -@using Apollo.Components.Infrastructure.MessageBus +@using Mythetech.Framework.Infrastructure.MessageBus @using Apollo.Components.Theme @using MouseEvent = MudBlazor.MouseEvent diff --git a/Apollo.Components/Hosting/Consumers/HostingShutdown.cs b/Apollo.Components/Hosting/Consumers/HostingShutdown.cs index f08c122..cee39e2 100644 --- a/Apollo.Components/Hosting/Consumers/HostingShutdown.cs +++ b/Apollo.Components/Hosting/Consumers/HostingShutdown.cs @@ -1,5 +1,5 @@ using Apollo.Components.Hosting.Commands; -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; namespace Apollo.Components.Hosting.Consumers; diff --git a/Apollo.Components/Hosting/Consumers/WebApiProjectBuilder.cs b/Apollo.Components/Hosting/Consumers/WebApiProjectBuilder.cs index 5b34cd5..0703569 100644 --- a/Apollo.Components/Hosting/Consumers/WebApiProjectBuilder.cs +++ b/Apollo.Components/Hosting/Consumers/WebApiProjectBuilder.cs @@ -1,6 +1,6 @@ using Apollo.Components.DynamicTabs; using Apollo.Components.DynamicTabs.Commands; -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Solutions; using Apollo.Components.Solutions.Commands; using Apollo.Contracts.Solutions; diff --git a/Apollo.Components/Hosting/IHostingService.cs b/Apollo.Components/Hosting/IHostingService.cs index 19b5332..5f332ff 100644 --- a/Apollo.Components/Hosting/IHostingService.cs +++ b/Apollo.Components/Hosting/IHostingService.cs @@ -2,7 +2,7 @@ using Apollo.Components.Console; using Apollo.Components.DynamicTabs.Commands; using Apollo.Components.Hosting.Events; -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.NuGet; using Apollo.Components.Solutions; using Apollo.Contracts.Hosting; diff --git a/Apollo.Components/Hosting/WebApiRouteTab.razor b/Apollo.Components/Hosting/WebApiRouteTab.razor index a41ab26..c63ebe8 100644 --- a/Apollo.Components/Hosting/WebApiRouteTab.razor +++ b/Apollo.Components/Hosting/WebApiRouteTab.razor @@ -2,7 +2,7 @@ @using Apollo.Components.DynamicTabs @using Apollo.Components.DynamicTabs.Commands @using Apollo.Components.Hosting.Commands -@using Apollo.Components.Infrastructure.MessageBus +@using Mythetech.Framework.Infrastructure.MessageBus @using Apollo.Components.Shared @using Apollo.Components.Shared.ApolloNotificationBar @using Apollo.Components.Solutions diff --git a/Apollo.Components/Infrastructure/Keyboard/KeyboardService.cs b/Apollo.Components/Infrastructure/Keyboard/KeyboardService.cs index 3397579..6f6d088 100644 --- a/Apollo.Components/Infrastructure/Keyboard/KeyboardService.cs +++ b/Apollo.Components/Infrastructure/Keyboard/KeyboardService.cs @@ -1,6 +1,6 @@ using Apollo.Components.DynamicTabs.Commands; using Apollo.Components.Hosting.Commands; -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Settings.Commands; using Apollo.Components.Solutions.Commands; using Microsoft.FluentUI.AspNetCore.Components; diff --git a/Apollo.Components/Infrastructure/MessageBus/BusRegistrationExtensions.cs b/Apollo.Components/Infrastructure/MessageBus/BusRegistrationExtensions.cs deleted file mode 100644 index b2ae28f..0000000 --- a/Apollo.Components/Infrastructure/MessageBus/BusRegistrationExtensions.cs +++ /dev/null @@ -1,91 +0,0 @@ -using System.Reflection; -using Microsoft.AspNetCore.Components; -using Microsoft.Extensions.DependencyInjection; -using Apollo.Components.Solutions.Services; -using Apollo.Components.Solutions.Commands; -using Assembly = System.Reflection.Assembly; - -namespace Apollo.Components.Infrastructure.MessageBus; - -public static class BusRegistrationExtensions -{ - public static void RegisterConsumers(this IServiceCollection services, Assembly assembly) - { - var consumerTypes = assembly - .GetTypes() - .Where(t => !t.IsAbstract && !t.IsInterface) - .SelectMany(t => t.GetInterfaces() - .Where(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IConsumer<>)) - .Select(i => new { ConsumerType = t, MessageType = i.GetGenericArguments()[0] })) - .Where(c => !typeof(ComponentBase).IsAssignableFrom(c.ConsumerType)); - - foreach (var consumer in consumerTypes) - { - services.AddTransient(consumer.ConsumerType); - } - } - - public static void RegisterConsumersToBus(this IMessageBus bus, Assembly assembly) - { - var consumerTypes = assembly - .GetTypes() - .Where(t => !t.IsAbstract && !t.IsInterface) - .SelectMany(t => t.GetInterfaces() - .Where(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IConsumer<>)) - .Select(i => new { ConsumerType = t, MessageType = i.GetGenericArguments()[0] })) - .Where(c => !typeof(ComponentBase).IsAssignableFrom(c.ConsumerType)); - - foreach (var consumer in consumerTypes) - { - bus.RegisterConsumerType(consumer.MessageType, consumer.ConsumerType); - } - } - - public static void RegisterConsumerType(this IMessageBus bus, Type messageType, Type consumerType) - { - var method = typeof(IMessageBus).GetMethod(nameof(IMessageBus.RegisterConsumerType))? - .MakeGenericMethod(messageType, consumerType); - method?.Invoke(bus, null); - } - - public static IServiceCollection AddMessageBus(this IServiceCollection services) - { - services.AddSingleton(); - services.AddSingleton(); - - services.RegisterConsumers(Assembly.GetExecutingAssembly()); - - return services; - } - - public static IServiceCollection AddMessageBus(this IServiceCollection services, params Assembly[] assemblies) - { - services.AddSingleton(); - services.AddSingleton(); - - foreach (var assembly in assemblies) - { - services.RegisterConsumers(assembly); - } - - return services; - } - - public static IServiceProvider UseMessageBus(this IServiceProvider serviceProvider) - { - var bus = serviceProvider.GetService(); - bus.RegisterConsumersToBus(Assembly.GetExecutingAssembly()); - - return serviceProvider; - } - - public static IServiceProvider UseMessageBus(this IServiceProvider serviceProvider, params Assembly[] assemblies) - { - var bus = serviceProvider.GetService(); - foreach (var assembly in assemblies) - { - bus.RegisterConsumersToBus(assembly); - } - return serviceProvider; - } -} \ No newline at end of file diff --git a/Apollo.Components/Infrastructure/MessageBus/ComponentConsumer.cs b/Apollo.Components/Infrastructure/MessageBus/ComponentConsumer.cs deleted file mode 100644 index 89fed23..0000000 --- a/Apollo.Components/Infrastructure/MessageBus/ComponentConsumer.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Microsoft.AspNetCore.Components; - -namespace Apollo.Components.Infrastructure.MessageBus; - -public abstract class ComponentConsumer : ComponentBase, IConsumer, IDisposable where TMessage : class -{ - [Inject] - protected IMessageBus MessageBus { get; set; } = default!; - - protected override void OnInitialized() - { - base.OnInitialized(); - MessageBus.Subscribe(this); - - } - - public async Task Consume(TMessage message) - { - var cts = new CancellationTokenSource(); - await InvokeAsync(async () => await Consume(message, cts.Token)); - } - - protected abstract Task Consume(TMessage message, CancellationToken cancellationToken); - - public void Dispose() - { - MessageBus.Unsubscribe(this); - } -} \ No newline at end of file diff --git a/Apollo.Components/Infrastructure/MessageBus/IConsumer.cs b/Apollo.Components/Infrastructure/MessageBus/IConsumer.cs deleted file mode 100644 index dc1bb5e..0000000 --- a/Apollo.Components/Infrastructure/MessageBus/IConsumer.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Apollo.Components.Infrastructure.MessageBus; - -public interface IConsumer -{ - Task Consume(TMessage message); -} \ No newline at end of file diff --git a/Apollo.Components/Infrastructure/MessageBus/IMessageBus.cs b/Apollo.Components/Infrastructure/MessageBus/IMessageBus.cs deleted file mode 100644 index aff1e40..0000000 --- a/Apollo.Components/Infrastructure/MessageBus/IMessageBus.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace Apollo.Components.Infrastructure.MessageBus; - -public interface IMessageBus -{ - Task PublishAsync(TMessage message) where TMessage : class; - Task PublishAsync(Type messageType, object message); - - void RegisterConsumerType() where TMessage : class where TConsumer : IConsumer; - - void Subscribe(IConsumer consumer) where TMessage : class; - void Unsubscribe(IConsumer consumer) where TMessage : class; -} \ No newline at end of file diff --git a/Apollo.Components/Infrastructure/MessageBus/InMemoryMessageBus.cs b/Apollo.Components/Infrastructure/MessageBus/InMemoryMessageBus.cs deleted file mode 100644 index b2a7313..0000000 --- a/Apollo.Components/Infrastructure/MessageBus/InMemoryMessageBus.cs +++ /dev/null @@ -1,125 +0,0 @@ -namespace Apollo.Components.Infrastructure.MessageBus; -using Microsoft.Extensions.Logging; -using Apollo.Components.Infrastructure.Environment; - -public class InMemoryMessageBus : IMessageBus -{ - private readonly Dictionary> _registeredConsumerTypes = new(); - private readonly Dictionary> _cachedConsumers = new(); - private readonly Dictionary> _subscribers = new(); - - private readonly IServiceProvider _serviceProvider; - private readonly ILogger _logger; - private readonly CapturedEventState _capturedEventState; - - internal bool CaptureDebugInformation { get; } - - public InMemoryMessageBus( - IServiceProvider serviceProvider, - ILogger logger, - CapturedEventState capturedEventState, - IRuntimeEnvironment runtimeEnvironment) - { - _serviceProvider = serviceProvider; - _logger = logger; - _capturedEventState = capturedEventState; - CaptureDebugInformation = runtimeEnvironment.IsDevelopment(); - } - - public async Task PublishAsync(TMessage message) where TMessage : class - { - if (CaptureDebugInformation) - { - try - { - _capturedEventState.Add(typeof(TMessage), message); - } - catch (Exception ex) - { - _logger.LogError(ex, "Error capturing message {MessageType}", typeof(TMessage).Name); - } - } - - var registeredConsumers = GetOrResolveConsumers(); - - var manualSubscribers = _subscribers.TryGetValue(typeof(TMessage), out var subscribers) - ? subscribers.Cast>() - : []; - - var allConsumers = registeredConsumers.Concat(manualSubscribers); - - var tasks = allConsumers.Select(async consumer => - { - try - { - await consumer.Consume(message); - } - catch (Exception ex) - { - _logger.LogError(ex, - "Error in message bus consumer {ConsumerType} handling message {MessageType}", - consumer.GetType().Name, - typeof(TMessage).Name); - } - }); - - await Task.WhenAll(tasks); - } - - public async Task PublishAsync(Type messageType, object message) - { - var method = typeof(InMemoryMessageBus) - .GetMethod(nameof(PublishAsync), 1, [Type.MakeGenericMethodParameter(0)])! - .MakeGenericMethod(messageType); - - await (Task)method.Invoke(this, [message])!; - } - - public void RegisterConsumerType() where TMessage : class where TConsumer : IConsumer - { - if (!_registeredConsumerTypes.ContainsKey(typeof(TMessage))) - { - _registeredConsumerTypes[typeof(TMessage)] = new List(); - } - - _registeredConsumerTypes[typeof(TMessage)].Add(typeof(TConsumer)); - } - - private List> GetOrResolveConsumers() where TMessage : class - { - var messageType = typeof(TMessage); - - if (!_cachedConsumers.TryGetValue(messageType, out var cached)) - { - if (!_registeredConsumerTypes.TryGetValue(messageType, out var consumerTypes)) - return []; - - cached = consumerTypes - .Select(type => _serviceProvider.GetService(type)) - .Where(consumer => consumer is not null) - .ToList(); - - _cachedConsumers[messageType] = cached; - } - - return cached.Cast>().ToList(); - } - - public void Subscribe(IConsumer consumer) where TMessage : class - { - if (!_subscribers.ContainsKey(typeof(TMessage))) - _subscribers[typeof(TMessage)] = new List(); - - _subscribers[typeof(TMessage)].Add(consumer); - } - - public void Unsubscribe(IConsumer consumer) where TMessage : class - { - if (_subscribers.TryGetValue(typeof(TMessage), out var handlers)) - { - handlers.Remove(consumer); - if (handlers.Count == 0) - _subscribers.Remove(typeof(TMessage)); - } - } -} \ No newline at end of file diff --git a/Apollo.Components/Infrastructure/RegistrationExtensions.cs b/Apollo.Components/Infrastructure/RegistrationExtensions.cs index 600a992..a3bfef9 100644 --- a/Apollo.Components/Infrastructure/RegistrationExtensions.cs +++ b/Apollo.Components/Infrastructure/RegistrationExtensions.cs @@ -6,7 +6,7 @@ using Apollo.Components.Hosting; using Apollo.Components.Infrastructure.Keyboard; using Apollo.Components.Infrastructure.Logging; -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Library; using Apollo.Components.NuGet; using Apollo.Components.Settings; @@ -17,6 +17,7 @@ using Apollo.Components.Testing; using Apollo.Components.Theme; using Apollo.Components.DynamicClient; +using Apollo.Components.Tools.EventCapture; using Blazored.LocalStorage; using KristofferStrube.Blazor.FileSystemAccess; using Microsoft.Extensions.DependencyInjection; @@ -77,6 +78,10 @@ public static IServiceCollection AddComponentsAndServices(this IServiceCollectio services.AddSingleton(); services.AddSingleton(); + // Event capture for Event Viewer (development debugging) + services.AddSingleton(); + services.AddSingleton(); + services.AddTerminalCommands(); services.AddBlazoredLocalStorageAsSingleton(config => diff --git a/Apollo.Components/Library/LibraryTab.razor b/Apollo.Components/Library/LibraryTab.razor index 4a67497..8c9dbe8 100644 --- a/Apollo.Components/Library/LibraryTab.razor +++ b/Apollo.Components/Library/LibraryTab.razor @@ -1,5 +1,5 @@ @using Apollo.Components.DynamicTabs -@using Apollo.Components.Infrastructure.MessageBus +@using Mythetech.Framework.Infrastructure.MessageBus @using Apollo.Components.Shared @using Apollo.Components.Solutions @using Apollo.Components.Theme diff --git a/Apollo.Components/Library/SolutionOverviewCard.razor b/Apollo.Components/Library/SolutionOverviewCard.razor index df3eb67..2766cc1 100644 --- a/Apollo.Components/Library/SolutionOverviewCard.razor +++ b/Apollo.Components/Library/SolutionOverviewCard.razor @@ -1,4 +1,4 @@ -@using Apollo.Components.Infrastructure.MessageBus +@using Mythetech.Framework.Infrastructure.MessageBus @using Apollo.Components.Solutions @using Apollo.Components.Theme @using Microsoft.FluentUI.AspNetCore.Components.Extensions diff --git a/Apollo.Components/NuGet/Consumers/NuGetDialogOpener.cs b/Apollo.Components/NuGet/Consumers/NuGetDialogOpener.cs index f508053..0ff4934 100644 --- a/Apollo.Components/NuGet/Consumers/NuGetDialogOpener.cs +++ b/Apollo.Components/NuGet/Consumers/NuGetDialogOpener.cs @@ -1,4 +1,4 @@ -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.NuGet.Commands; using MudBlazor; diff --git a/Apollo.Components/NuGet/NuGetDialog.razor b/Apollo.Components/NuGet/NuGetDialog.razor index 04db781..d22c7f7 100644 --- a/Apollo.Components/NuGet/NuGetDialog.razor +++ b/Apollo.Components/NuGet/NuGetDialog.razor @@ -1,6 +1,6 @@ @using Apollo.Components.Theme @using Apollo.Components.Shared -@using Mythetech.Components.Components.SimpleTabs +@using Mythetech.Framework.Components.SimpleTabs @implements IDisposable diff --git a/Apollo.Components/Preview/PreviewTab.razor b/Apollo.Components/Preview/PreviewTab.razor index cc4a456..68d6b21 100644 --- a/Apollo.Components/Preview/PreviewTab.razor +++ b/Apollo.Components/Preview/PreviewTab.razor @@ -1,7 +1,7 @@ @using Apollo.Components.DynamicTabs @using Apollo.Components.Solutions @using Apollo.Components.Infrastructure -@using Apollo.Components.Infrastructure.MessageBus +@using Mythetech.Framework.Infrastructure.MessageBus @using Apollo.Components.Shared @using Microsoft.JSInterop @inherits DynamicTabView diff --git a/Apollo.Components/Settings/Consumers/AboutDialogOpener.cs b/Apollo.Components/Settings/Consumers/AboutDialogOpener.cs index 6676f76..428222c 100644 --- a/Apollo.Components/Settings/Consumers/AboutDialogOpener.cs +++ b/Apollo.Components/Settings/Consumers/AboutDialogOpener.cs @@ -1,5 +1,5 @@ using Apollo.Components.Editor; -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Settings.Commands; using MudBlazor; diff --git a/Apollo.Components/Settings/Consumers/AppSettingsPersister.cs b/Apollo.Components/Settings/Consumers/AppSettingsPersister.cs index fd18f5d..8fca289 100644 --- a/Apollo.Components/Settings/Consumers/AppSettingsPersister.cs +++ b/Apollo.Components/Settings/Consumers/AppSettingsPersister.cs @@ -1,5 +1,5 @@ using System.Text.Json; -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Settings.Events; using Blazored.LocalStorage; diff --git a/Apollo.Components/Settings/Consumers/GenericSettingsModelConverter.cs b/Apollo.Components/Settings/Consumers/GenericSettingsModelConverter.cs index c47f7de..96780f5 100644 --- a/Apollo.Components/Settings/Consumers/GenericSettingsModelConverter.cs +++ b/Apollo.Components/Settings/Consumers/GenericSettingsModelConverter.cs @@ -1,15 +1,25 @@ -using Apollo.Components.Infrastructure.MessageBus; +using System.Reflection; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Settings.Events; namespace Apollo.Components.Settings.Consumers; public class GenericSettingsModelConverter(IMessageBus bus) : IConsumer { + private static readonly MethodInfo PublishAsyncMethod = typeof(IMessageBus) + .GetMethods() + .First(m => m.Name == nameof(IMessageBus.PublishAsync) && + m.IsGenericMethod && + m.GetParameters().Length == 1); + public async Task Consume(SettingsModelChanged message) { var genericMessageType = typeof(SettingsModelChanged<>).MakeGenericType(message.Type); var instance = Activator.CreateInstance(genericMessageType, message.Model); - - await bus.PublishAsync(genericMessageType, instance!); + + // Use reflection to call PublishAsync with the runtime type + var method = PublishAsyncMethod.MakeGenericMethod(genericMessageType); + var task = (Task)method.Invoke(bus, [instance!])!; + await task; } } \ No newline at end of file diff --git a/Apollo.Components/Settings/Consumers/LocalStorageUserSettingsSaver.cs b/Apollo.Components/Settings/Consumers/LocalStorageUserSettingsSaver.cs index f3940b2..87bf378 100644 --- a/Apollo.Components/Settings/Consumers/LocalStorageUserSettingsSaver.cs +++ b/Apollo.Components/Settings/Consumers/LocalStorageUserSettingsSaver.cs @@ -1,4 +1,4 @@ -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Settings.Events; using Blazored.LocalStorage; diff --git a/Apollo.Components/Settings/Consumers/SettingsDialogOpener.cs b/Apollo.Components/Settings/Consumers/SettingsDialogOpener.cs index 719a3d2..32a1168 100644 --- a/Apollo.Components/Settings/Consumers/SettingsDialogOpener.cs +++ b/Apollo.Components/Settings/Consumers/SettingsDialogOpener.cs @@ -1,4 +1,4 @@ -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Settings.Commands; using MudBlazor; diff --git a/Apollo.Components/Settings/SettingsButton.razor b/Apollo.Components/Settings/SettingsButton.razor index b9a728e..1154ccf 100644 --- a/Apollo.Components/Settings/SettingsButton.razor +++ b/Apollo.Components/Settings/SettingsButton.razor @@ -1,4 +1,4 @@ -@using Apollo.Components.Infrastructure.MessageBus +@using Mythetech.Framework.Infrastructure.MessageBus @using Apollo.Components.Settings.Commands @using Apollo.Components.Theme @inject IMessageBus Bus diff --git a/Apollo.Components/Settings/SettingsDialog.razor b/Apollo.Components/Settings/SettingsDialog.razor index 9f1f411..d431995 100644 --- a/Apollo.Components/Settings/SettingsDialog.razor +++ b/Apollo.Components/Settings/SettingsDialog.razor @@ -4,7 +4,7 @@ @using Apollo.Components.Console @using Apollo.Components.Hosting @using Apollo.Components.Infrastructure.Keyboard -@using Apollo.Components.Infrastructure.MessageBus +@using Mythetech.Framework.Infrastructure.MessageBus @using Apollo.Components.Settings.Attributes @using Apollo.Components.Settings.Events @using Apollo.Components.Shared diff --git a/Apollo.Components/Settings/SettingsProvider.cs b/Apollo.Components/Settings/SettingsProvider.cs index 282e7ab..e8d7cd2 100644 --- a/Apollo.Components/Settings/SettingsProvider.cs +++ b/Apollo.Components/Settings/SettingsProvider.cs @@ -1,6 +1,6 @@ using System.Text.Json; using Apollo.Components.Editor; -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Settings.Events; namespace Apollo.Components.Settings; diff --git a/Apollo.Components/Settings/SettingsState.cs b/Apollo.Components/Settings/SettingsState.cs index 8b67d8d..583b8bb 100644 --- a/Apollo.Components/Settings/SettingsState.cs +++ b/Apollo.Components/Settings/SettingsState.cs @@ -1,4 +1,4 @@ -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Settings.Events; using Blazored.LocalStorage; using Microsoft.AspNetCore.Components; diff --git a/Apollo.Components/Settings/ThemeCustomizer.razor b/Apollo.Components/Settings/ThemeCustomizer.razor index 287a50f..01eaef0 100644 --- a/Apollo.Components/Settings/ThemeCustomizer.razor +++ b/Apollo.Components/Settings/ThemeCustomizer.razor @@ -2,7 +2,7 @@ @using Apollo.Components.Shared @using MudBlazor.Utilities @using Microsoft.JSInterop -@using Mythetech.Components.Components.SimpleTabs +@using Mythetech.Framework.Components.SimpleTabs diff --git a/Apollo.Components/Solutions/Commands/PromptOpenBase64Solution.cs b/Apollo.Components/Solutions/Commands/PromptOpenBase64Solution.cs index bdbe74a..6aec161 100644 --- a/Apollo.Components/Solutions/Commands/PromptOpenBase64Solution.cs +++ b/Apollo.Components/Solutions/Commands/PromptOpenBase64Solution.cs @@ -1,4 +1,4 @@ -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Shared.ApolloNotificationBar; using Apollo.Components.Solutions.Services; using MudBlazor; diff --git a/Apollo.Components/Solutions/Commands/ShareSolution.cs b/Apollo.Components/Solutions/Commands/ShareSolution.cs index 9861a75..3ab8cf7 100644 --- a/Apollo.Components/Solutions/Commands/ShareSolution.cs +++ b/Apollo.Components/Solutions/Commands/ShareSolution.cs @@ -1,4 +1,4 @@ -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Shared.ApolloNotificationBar; using Apollo.Components.Solutions.Services; using Microsoft.AspNetCore.Components; diff --git a/Apollo.Components/Solutions/Consumers/ActiveFileCopier.cs b/Apollo.Components/Solutions/Consumers/ActiveFileCopier.cs index 2c18ead..6d008a0 100644 --- a/Apollo.Components/Solutions/Consumers/ActiveFileCopier.cs +++ b/Apollo.Components/Solutions/Consumers/ActiveFileCopier.cs @@ -1,4 +1,4 @@ -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Solutions.Commands; using MudBlazor; diff --git a/Apollo.Components/Solutions/Consumers/Base64Exporter.cs b/Apollo.Components/Solutions/Consumers/Base64Exporter.cs index 76ecdf3..57770ad 100644 --- a/Apollo.Components/Solutions/Consumers/Base64Exporter.cs +++ b/Apollo.Components/Solutions/Consumers/Base64Exporter.cs @@ -1,4 +1,4 @@ -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Shared.ApolloNotificationBar; using Apollo.Components.Solutions.Commands; using Apollo.Components.Solutions.Services; diff --git a/Apollo.Components/Solutions/Consumers/BuildRequestSolutionSaver.cs b/Apollo.Components/Solutions/Consumers/BuildRequestSolutionSaver.cs index ac0faa7..02757c3 100644 --- a/Apollo.Components/Solutions/Consumers/BuildRequestSolutionSaver.cs +++ b/Apollo.Components/Solutions/Consumers/BuildRequestSolutionSaver.cs @@ -1,5 +1,5 @@ using Apollo.Components.Infrastructure; -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Solutions.Events; using Apollo.Components.Solutions.Services; diff --git a/Apollo.Components/Solutions/Consumers/CreateNewFilePrompter.cs b/Apollo.Components/Solutions/Consumers/CreateNewFilePrompter.cs index 057c853..cb9a040 100644 --- a/Apollo.Components/Solutions/Consumers/CreateNewFilePrompter.cs +++ b/Apollo.Components/Solutions/Consumers/CreateNewFilePrompter.cs @@ -1,4 +1,4 @@ -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Solutions.Commands; using MudBlazor; diff --git a/Apollo.Components/Solutions/Consumers/CreateNewSolutionPrompter.cs b/Apollo.Components/Solutions/Consumers/CreateNewSolutionPrompter.cs index 1f374e5..eb63277 100644 --- a/Apollo.Components/Solutions/Consumers/CreateNewSolutionPrompter.cs +++ b/Apollo.Components/Solutions/Consumers/CreateNewSolutionPrompter.cs @@ -1,4 +1,4 @@ -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Solutions.Commands; using Microsoft.Extensions.DependencyInjection; using MudBlazor; diff --git a/Apollo.Components/Solutions/Consumers/DeleteSolutionPrompter.cs b/Apollo.Components/Solutions/Consumers/DeleteSolutionPrompter.cs index 445fef5..7fb1d3d 100644 --- a/Apollo.Components/Solutions/Consumers/DeleteSolutionPrompter.cs +++ b/Apollo.Components/Solutions/Consumers/DeleteSolutionPrompter.cs @@ -1,4 +1,4 @@ -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Shared.ApolloNotificationBar; using Apollo.Components.Solutions.Commands; using Apollo.Components.Solutions.Events; diff --git a/Apollo.Components/Solutions/Consumers/DocumentFormatter.cs b/Apollo.Components/Solutions/Consumers/DocumentFormatter.cs index 9e27a86..3c1201b 100644 --- a/Apollo.Components/Solutions/Consumers/DocumentFormatter.cs +++ b/Apollo.Components/Solutions/Consumers/DocumentFormatter.cs @@ -1,5 +1,5 @@ using Apollo.Components.Infrastructure; -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Shared.ApolloNotificationBar; using Apollo.Components.Solutions.Commands; using Microsoft.Extensions.Logging; diff --git a/Apollo.Components/Solutions/Consumers/FileDeleter.cs b/Apollo.Components/Solutions/Consumers/FileDeleter.cs index f3bd549..52e4253 100644 --- a/Apollo.Components/Solutions/Consumers/FileDeleter.cs +++ b/Apollo.Components/Solutions/Consumers/FileDeleter.cs @@ -1,4 +1,4 @@ -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Solutions.Commands; namespace Apollo.Components.Solutions.Consumers; diff --git a/Apollo.Components/Solutions/Consumers/FileMover.cs b/Apollo.Components/Solutions/Consumers/FileMover.cs index 6decef8..cc1862b 100644 --- a/Apollo.Components/Solutions/Consumers/FileMover.cs +++ b/Apollo.Components/Solutions/Consumers/FileMover.cs @@ -1,6 +1,6 @@ using System; using System.Threading.Tasks; -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Solutions.Commands; namespace Apollo.Components.Solutions.Consumers diff --git a/Apollo.Components/Solutions/Consumers/FileOpener.cs b/Apollo.Components/Solutions/Consumers/FileOpener.cs index e83ffc8..4d1680c 100644 --- a/Apollo.Components/Solutions/Consumers/FileOpener.cs +++ b/Apollo.Components/Solutions/Consumers/FileOpener.cs @@ -1,4 +1,4 @@ -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Shared.ApolloNotificationBar; using Apollo.Components.Solutions.Commands; using KristofferStrube.Blazor.FileSystem; diff --git a/Apollo.Components/Solutions/Consumers/FolderDeleter.cs b/Apollo.Components/Solutions/Consumers/FolderDeleter.cs index 52e2db1..f454802 100644 --- a/Apollo.Components/Solutions/Consumers/FolderDeleter.cs +++ b/Apollo.Components/Solutions/Consumers/FolderDeleter.cs @@ -1,4 +1,4 @@ -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Solutions.Commands; namespace Apollo.Components.Solutions.Consumers; diff --git a/Apollo.Components/Solutions/Consumers/FolderOpener.cs b/Apollo.Components/Solutions/Consumers/FolderOpener.cs index acf10b4..aab2283 100644 --- a/Apollo.Components/Solutions/Consumers/FolderOpener.cs +++ b/Apollo.Components/Solutions/Consumers/FolderOpener.cs @@ -1,4 +1,4 @@ -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Shared.ApolloNotificationBar; using Apollo.Components.Solutions.Commands; using KristofferStrube.Blazor.FileSystem; diff --git a/Apollo.Components/Solutions/Consumers/GitHubRepositoryOpener.cs b/Apollo.Components/Solutions/Consumers/GitHubRepositoryOpener.cs index 926b5f2..8bf7423 100644 --- a/Apollo.Components/Solutions/Consumers/GitHubRepositoryOpener.cs +++ b/Apollo.Components/Solutions/Consumers/GitHubRepositoryOpener.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Threading.Tasks; -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Microsoft.Extensions.DependencyInjection; using MudBlazor; using Apollo.Components.Shared; diff --git a/Apollo.Components/Solutions/Consumers/JsonExporter.cs b/Apollo.Components/Solutions/Consumers/JsonExporter.cs index ba658f0..2ab18fd 100644 --- a/Apollo.Components/Solutions/Consumers/JsonExporter.cs +++ b/Apollo.Components/Solutions/Consumers/JsonExporter.cs @@ -1,5 +1,5 @@ using System.Text.Json; -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Shared; using Apollo.Components.Solutions.Commands; using Microsoft.JSInterop; diff --git a/Apollo.Components/Solutions/Consumers/OpenBase64SolutionPrompter.cs b/Apollo.Components/Solutions/Consumers/OpenBase64SolutionPrompter.cs index 29a17f9..cdafbc8 100644 --- a/Apollo.Components/Solutions/Consumers/OpenBase64SolutionPrompter.cs +++ b/Apollo.Components/Solutions/Consumers/OpenBase64SolutionPrompter.cs @@ -1,4 +1,4 @@ -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Shared.ApolloNotificationBar; using Apollo.Components.Solutions.Commands; using Apollo.Components.Solutions.Services; diff --git a/Apollo.Components/Solutions/Consumers/ProjectRenamedSolutionSaver.cs b/Apollo.Components/Solutions/Consumers/ProjectRenamedSolutionSaver.cs index ee7ee7c..48dbb82 100644 --- a/Apollo.Components/Solutions/Consumers/ProjectRenamedSolutionSaver.cs +++ b/Apollo.Components/Solutions/Consumers/ProjectRenamedSolutionSaver.cs @@ -1,5 +1,5 @@ using Apollo.Components.Infrastructure; -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Solutions.Events; using Apollo.Components.Solutions.Services; diff --git a/Apollo.Components/Solutions/Consumers/RenameFile.cs b/Apollo.Components/Solutions/Consumers/RenameFile.cs index 7fa6f25..e0a1f73 100644 --- a/Apollo.Components/Solutions/Consumers/RenameFile.cs +++ b/Apollo.Components/Solutions/Consumers/RenameFile.cs @@ -1,4 +1,4 @@ -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Solutions.Commands; namespace Apollo.Components.Solutions.Consumers; diff --git a/Apollo.Components/Solutions/Consumers/SaveSolution.cs b/Apollo.Components/Solutions/Consumers/SaveSolution.cs index f9f4881..63732d9 100644 --- a/Apollo.Components/Solutions/Consumers/SaveSolution.cs +++ b/Apollo.Components/Solutions/Consumers/SaveSolution.cs @@ -1,5 +1,5 @@ using Apollo.Components.Infrastructure; -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Solutions.Commands; using Apollo.Components.Solutions.Services; diff --git a/Apollo.Components/Solutions/Consumers/SaveSolutionAsPrompter.cs b/Apollo.Components/Solutions/Consumers/SaveSolutionAsPrompter.cs index 4d581cb..4112c5b 100644 --- a/Apollo.Components/Solutions/Consumers/SaveSolutionAsPrompter.cs +++ b/Apollo.Components/Solutions/Consumers/SaveSolutionAsPrompter.cs @@ -1,4 +1,4 @@ -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Solutions.Commands; using Apollo.Components.Solutions.Services; using MudBlazor; diff --git a/Apollo.Components/Solutions/Consumers/SolutionBuilder.cs b/Apollo.Components/Solutions/Consumers/SolutionBuilder.cs index 78d28ad..d3e8ffb 100644 --- a/Apollo.Components/Solutions/Consumers/SolutionBuilder.cs +++ b/Apollo.Components/Solutions/Consumers/SolutionBuilder.cs @@ -1,4 +1,4 @@ -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Solutions.Commands; namespace Apollo.Components.Solutions.Consumers; diff --git a/Apollo.Components/Solutions/Consumers/SolutionCloner.cs b/Apollo.Components/Solutions/Consumers/SolutionCloner.cs index 122f174..966e3c1 100644 --- a/Apollo.Components/Solutions/Consumers/SolutionCloner.cs +++ b/Apollo.Components/Solutions/Consumers/SolutionCloner.cs @@ -1,5 +1,5 @@ using Apollo.Components.Infrastructure; -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Solutions.Commands; using Apollo.Components.Solutions.Services; diff --git a/Apollo.Components/Solutions/Consumers/SolutionCloser.cs b/Apollo.Components/Solutions/Consumers/SolutionCloser.cs index d20ed19..d3ad819 100644 --- a/Apollo.Components/Solutions/Consumers/SolutionCloser.cs +++ b/Apollo.Components/Solutions/Consumers/SolutionCloser.cs @@ -1,4 +1,4 @@ -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Solutions.Commands; namespace Apollo.Components.Solutions.Consumers; diff --git a/Apollo.Components/Solutions/Consumers/SolutionCreatedSaver.cs b/Apollo.Components/Solutions/Consumers/SolutionCreatedSaver.cs index 7114de2..351a4bd 100644 --- a/Apollo.Components/Solutions/Consumers/SolutionCreatedSaver.cs +++ b/Apollo.Components/Solutions/Consumers/SolutionCreatedSaver.cs @@ -1,5 +1,5 @@ using Apollo.Components.Infrastructure; -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Solutions.Events; using Apollo.Components.Solutions.Services; diff --git a/Apollo.Components/Solutions/Consumers/SolutionDeletedHandler.cs b/Apollo.Components/Solutions/Consumers/SolutionDeletedHandler.cs index cbca7e7..983df0d 100644 --- a/Apollo.Components/Solutions/Consumers/SolutionDeletedHandler.cs +++ b/Apollo.Components/Solutions/Consumers/SolutionDeletedHandler.cs @@ -1,5 +1,5 @@ using Apollo.Components.Infrastructure; -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Solutions.Events; using Apollo.Components.Solutions.Services; diff --git a/Apollo.Components/Solutions/Consumers/SolutionLoader.cs b/Apollo.Components/Solutions/Consumers/SolutionLoader.cs index e5e9fc0..c71f14c 100644 --- a/Apollo.Components/Solutions/Consumers/SolutionLoader.cs +++ b/Apollo.Components/Solutions/Consumers/SolutionLoader.cs @@ -1,4 +1,4 @@ -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Solutions.Commands; namespace Apollo.Components.Solutions.Consumers; diff --git a/Apollo.Components/Solutions/Consumers/SolutionRunner.cs b/Apollo.Components/Solutions/Consumers/SolutionRunner.cs index 3366303..b10c5b4 100644 --- a/Apollo.Components/Solutions/Consumers/SolutionRunner.cs +++ b/Apollo.Components/Solutions/Consumers/SolutionRunner.cs @@ -1,4 +1,4 @@ -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Solutions.Commands; namespace Apollo.Components.Solutions.Consumers; diff --git a/Apollo.Components/Solutions/Consumers/VisualStudioExporter.cs b/Apollo.Components/Solutions/Consumers/VisualStudioExporter.cs index 6cb093b..9f0866c 100644 --- a/Apollo.Components/Solutions/Consumers/VisualStudioExporter.cs +++ b/Apollo.Components/Solutions/Consumers/VisualStudioExporter.cs @@ -1,5 +1,5 @@ using System.IO.Compression; -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Shared; using Apollo.Components.Solutions.Commands; using Apollo.Contracts.Solutions; diff --git a/Apollo.Components/Solutions/Consumers/ZipExporter.cs b/Apollo.Components/Solutions/Consumers/ZipExporter.cs index 658e652..66140dc 100644 --- a/Apollo.Components/Solutions/Consumers/ZipExporter.cs +++ b/Apollo.Components/Solutions/Consumers/ZipExporter.cs @@ -1,5 +1,5 @@ using System.IO.Compression; -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Shared; using Apollo.Components.Solutions.Commands; using Microsoft.JSInterop; diff --git a/Apollo.Components/Solutions/SolutionExplorerTab.razor b/Apollo.Components/Solutions/SolutionExplorerTab.razor index 7b0e9a0..d93cfdd 100644 --- a/Apollo.Components/Solutions/SolutionExplorerTab.razor +++ b/Apollo.Components/Solutions/SolutionExplorerTab.razor @@ -1,5 +1,6 @@ @using Apollo.Components.DynamicTabs -@using Apollo.Components.Infrastructure.MessageBus +@using Mythetech.Framework.Infrastructure.MessageBus +@using Mythetech.Framework.Components.HoverStack @using MouseEvent = MudBlazor.MouseEvent @using Apollo.Components.Shared @using Apollo.Components.Solutions.Commands @@ -43,13 +44,16 @@ - + @_rootFolder?.Name - - - - + @if (hover.IsHovering) + { + + + + } + diff --git a/Apollo.Components/Solutions/SolutionTree.razor b/Apollo.Components/Solutions/SolutionTree.razor index e72f0d3..5e6354f 100644 --- a/Apollo.Components/Solutions/SolutionTree.razor +++ b/Apollo.Components/Solutions/SolutionTree.razor @@ -1,4 +1,5 @@ -@using Apollo.Components.Infrastructure.MessageBus +@using Mythetech.Framework.Infrastructure.MessageBus +@using Mythetech.Framework.Components.HoverStack @using MouseEvent = MudBlazor.MouseEvent @using Apollo.Components.Shared @using Apollo.Components.Solutions.Commands @@ -12,14 +13,17 @@ { - + @folder.Name - - - - - + @if (hover.IsHovering) + { + + + + + } + diff --git a/Apollo.Components/Solutions/SolutionsState.cs b/Apollo.Components/Solutions/SolutionsState.cs index 7d4087b..3b36f49 100644 --- a/Apollo.Components/Solutions/SolutionsState.cs +++ b/Apollo.Components/Solutions/SolutionsState.cs @@ -2,7 +2,7 @@ using Apollo.Components.DynamicTabs.Commands; using Apollo.Components.Hosting; using Apollo.Components.Infrastructure; -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Library.SampleProjects; using Apollo.Components.Solutions.Commands; using Apollo.Components.Solutions.Events; diff --git a/Apollo.Components/Terminal/ApolloTerminal.razor b/Apollo.Components/Terminal/ApolloTerminal.razor index bf96584..3ee67f1 100644 --- a/Apollo.Components/Terminal/ApolloTerminal.razor +++ b/Apollo.Components/Terminal/ApolloTerminal.razor @@ -1,6 +1,6 @@ @using System.Text.RegularExpressions @using Apollo.Components.Console -@using Apollo.Components.Infrastructure.MessageBus +@using Mythetech.Framework.Infrastructure.MessageBus @using Apollo.Components.Solutions.Commands @using Apollo.Components.Terminal.Models @using Microsoft.JSInterop diff --git a/Apollo.Components/Terminal/CommandServices/ExceptionCommand.cs b/Apollo.Components/Terminal/CommandServices/ExceptionCommand.cs index d527e1c..5ae4728 100644 --- a/Apollo.Components/Terminal/CommandServices/ExceptionCommand.cs +++ b/Apollo.Components/Terminal/CommandServices/ExceptionCommand.cs @@ -1,4 +1,4 @@ -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Terminal.Commands; using Microsoft.AspNetCore.Components; using Microsoft.Extensions.Logging; diff --git a/Apollo.Components/Terminal/CommandServices/RunCommand.cs b/Apollo.Components/Terminal/CommandServices/RunCommand.cs index e70f4c0..ff46258 100644 --- a/Apollo.Components/Terminal/CommandServices/RunCommand.cs +++ b/Apollo.Components/Terminal/CommandServices/RunCommand.cs @@ -1,4 +1,4 @@ -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Solutions.Commands; namespace Apollo.Components.Terminal.CommandServices; diff --git a/Apollo.Components/Terminal/Commands/TestException.cs b/Apollo.Components/Terminal/Commands/TestException.cs index ffec19b..0422572 100644 --- a/Apollo.Components/Terminal/Commands/TestException.cs +++ b/Apollo.Components/Terminal/Commands/TestException.cs @@ -1,4 +1,4 @@ -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Microsoft.Extensions.Logging; namespace Apollo.Components.Terminal.Commands; diff --git a/Apollo.Components/Testing/Consumers/BuildCompletedConsumer.cs b/Apollo.Components/Testing/Consumers/BuildCompletedConsumer.cs index 0034a75..2704019 100644 --- a/Apollo.Components/Testing/Consumers/BuildCompletedConsumer.cs +++ b/Apollo.Components/Testing/Consumers/BuildCompletedConsumer.cs @@ -1,4 +1,4 @@ -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Solutions.Events; namespace Apollo.Components.Testing.Consumers; diff --git a/Apollo.Components/Tools/Consumers/EventViewerDialogOpener.cs b/Apollo.Components/Tools/Consumers/EventViewerDialogOpener.cs index 78c1279..7fd0758 100644 --- a/Apollo.Components/Tools/Consumers/EventViewerDialogOpener.cs +++ b/Apollo.Components/Tools/Consumers/EventViewerDialogOpener.cs @@ -1,4 +1,4 @@ -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Tools.Commands; using MudBlazor; diff --git a/Apollo.Components/Tools/Consumers/GuidGenerator.cs b/Apollo.Components/Tools/Consumers/GuidGenerator.cs index f8e2aa6..214ecc9 100644 --- a/Apollo.Components/Tools/Consumers/GuidGenerator.cs +++ b/Apollo.Components/Tools/Consumers/GuidGenerator.cs @@ -1,4 +1,4 @@ -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Shared.ApolloNotificationBar; using Apollo.Components.Tools.Commands; using MudBlazor; diff --git a/Apollo.Components/Tools/Consumers/GuidV7Generator.cs b/Apollo.Components/Tools/Consumers/GuidV7Generator.cs index 5869f8f..264990c 100644 --- a/Apollo.Components/Tools/Consumers/GuidV7Generator.cs +++ b/Apollo.Components/Tools/Consumers/GuidV7Generator.cs @@ -1,4 +1,4 @@ -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Shared.ApolloNotificationBar; using Apollo.Components.Tools.Commands; using MudBlazor; diff --git a/Apollo.Components/Tools/Consumers/JsonFormatterDialogOpener.cs b/Apollo.Components/Tools/Consumers/JsonFormatterDialogOpener.cs index 6263a27..85f4d4f 100644 --- a/Apollo.Components/Tools/Consumers/JsonFormatterDialogOpener.cs +++ b/Apollo.Components/Tools/Consumers/JsonFormatterDialogOpener.cs @@ -1,4 +1,4 @@ -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Tools.Commands; using MudBlazor; diff --git a/Apollo.Components/Tools/Consumers/JsonToCSharpDialogOpener.cs b/Apollo.Components/Tools/Consumers/JsonToCSharpDialogOpener.cs index d103563..96efbe6 100644 --- a/Apollo.Components/Tools/Consumers/JsonToCSharpDialogOpener.cs +++ b/Apollo.Components/Tools/Consumers/JsonToCSharpDialogOpener.cs @@ -1,4 +1,4 @@ -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Tools.Commands; using MudBlazor; diff --git a/Apollo.Components/Tools/Consumers/RegexTesterDialogOpener.cs b/Apollo.Components/Tools/Consumers/RegexTesterDialogOpener.cs index 298b232..fbec72f 100644 --- a/Apollo.Components/Tools/Consumers/RegexTesterDialogOpener.cs +++ b/Apollo.Components/Tools/Consumers/RegexTesterDialogOpener.cs @@ -1,4 +1,4 @@ -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Tools.Commands; using MudBlazor; diff --git a/Apollo.Components/Tools/EventCapture/CapturedEvent.cs b/Apollo.Components/Tools/EventCapture/CapturedEvent.cs new file mode 100644 index 0000000..4e45fc9 --- /dev/null +++ b/Apollo.Components/Tools/EventCapture/CapturedEvent.cs @@ -0,0 +1,11 @@ +namespace Apollo.Components.Tools.EventCapture; + +public sealed record CapturedEvent( + Guid Id, + DateTimeOffset Timestamp, + string EventType, + string Payload); + +public sealed record CapturedEventAggregate( + string EventType, + int Count); diff --git a/Apollo.Components/Tools/EventCapture/CapturedEventPipe.cs b/Apollo.Components/Tools/EventCapture/CapturedEventPipe.cs new file mode 100644 index 0000000..d39f865 --- /dev/null +++ b/Apollo.Components/Tools/EventCapture/CapturedEventPipe.cs @@ -0,0 +1,23 @@ +using Mythetech.Framework.Infrastructure.MessageBus; + +namespace Apollo.Components.Tools.EventCapture; + +/// +/// A message pipe that captures all events for debugging/viewing in the Event Viewer. +/// +public sealed class CapturedEventPipe : IMessagePipe +{ + private readonly CapturedEventState _state; + + public CapturedEventPipe(CapturedEventState state) + { + _state = state; + } + + public Task ProcessAsync(TMessage message, CancellationToken cancellationToken) + where TMessage : class + { + _state.Add(typeof(TMessage), message); + return Task.FromResult(true); + } +} diff --git a/Apollo.Components/Infrastructure/MessageBus/CapturedEventState.cs b/Apollo.Components/Tools/EventCapture/CapturedEventState.cs similarity index 86% rename from Apollo.Components/Infrastructure/MessageBus/CapturedEventState.cs rename to Apollo.Components/Tools/EventCapture/CapturedEventState.cs index 2a2d8bd..1795346 100644 --- a/Apollo.Components/Infrastructure/MessageBus/CapturedEventState.cs +++ b/Apollo.Components/Tools/EventCapture/CapturedEventState.cs @@ -1,6 +1,6 @@ using System.Text.Json; -namespace Apollo.Components.Infrastructure.MessageBus; +namespace Apollo.Components.Tools.EventCapture; public sealed class CapturedEventState { @@ -77,15 +77,3 @@ private void TrimToMax() _events.RemoveRange(0, overflow); } } - -public sealed record CapturedEvent( - Guid Id, - DateTimeOffset Timestamp, - string EventType, - string Payload); - -public sealed record CapturedEventAggregate( - string EventType, - int Count); - - diff --git a/Apollo.Components/Tools/EventViewerDialog.razor b/Apollo.Components/Tools/EventViewerDialog.razor index cbc84c8..fa4db81 100644 --- a/Apollo.Components/Tools/EventViewerDialog.razor +++ b/Apollo.Components/Tools/EventViewerDialog.razor @@ -1,6 +1,6 @@ -@using Apollo.Components.Infrastructure.MessageBus +@using Apollo.Components.Tools.EventCapture @using Apollo.Components.Theme -@using Mythetech.Components.Components.SimpleTabs +@using Mythetech.Framework.Components.SimpleTabs @using MudBlazor @using MudBlazor.Charts @implements IDisposable diff --git a/Apollo.Components/wwwroot/app.css b/Apollo.Components/wwwroot/app.css index f937007..d98f3d1 100644 --- a/Apollo.Components/wwwroot/app.css +++ b/Apollo.Components/wwwroot/app.css @@ -56,6 +56,14 @@ body { min-width: 180px; } +.w-100 { + width: 100%; +} + +.h-100 { + height: 100%; +} + .text-nowrap { text-wrap: nowrap!important; } diff --git a/Apollo.Test/Components/Code/ActiveTypeStateTests.cs b/Apollo.Test/Components/Code/ActiveTypeStateTests.cs index f4c2398..ba0d96b 100644 --- a/Apollo.Test/Components/Code/ActiveTypeStateTests.cs +++ b/Apollo.Test/Components/Code/ActiveTypeStateTests.cs @@ -1,11 +1,13 @@ using System.Reflection; using Apollo.Components.Code; using Apollo.Components.Infrastructure.Environment; -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.Library.SampleProjects; using Apollo.Components.Solutions.Events; using Bunit; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using NSubstitute; using Shouldly; using Xunit; @@ -14,12 +16,17 @@ namespace Apollo.Test.Components.Code; public class ActiveTypeStateTests : ApolloBaseTestContext { private ActiveTypeState _state; - + private IMessageBus _bus; + public ActiveTypeStateTests() { Services.AddSingleton(new TestRuntimeEnvironment()); - Services.AddSingleton(); - Services.AddSingleton(); + _bus = new InMemoryMessageBus( + Services, + Substitute.For>(), + Enumerable.Empty(), + Enumerable.Empty()); + Services.AddSingleton(_bus); _state = new ActiveTypeState(); } @@ -28,13 +35,12 @@ public async Task Handles_BuildCompleted_AndSetsTypes() { // Arrange var project = SimpleLibraryProject.Create(); - var bus = Services.GetRequiredService(); - bus.Subscribe(_state); + _bus.Subscribe(_state); // Act var result = TestCompiler.Compile(project); var asm = Assembly.Load(result.Assembly); - await bus.PublishAsync(new BuildCompleted(new CompilationResult(result.Success, asm))); + await _bus.PublishAsync(new BuildCompleted(new CompilationResult(result.Success, asm))); // Assert _state.Types.ShouldNotBeNull(); diff --git a/Apollo.Test/Components/Infrastructure/MessageBus/MessageBusTests.cs b/Apollo.Test/Components/Infrastructure/MessageBus/MessageBusTests.cs index 6a709f6..c78b66e 100644 --- a/Apollo.Test/Components/Infrastructure/MessageBus/MessageBusTests.cs +++ b/Apollo.Test/Components/Infrastructure/MessageBus/MessageBusTests.cs @@ -1,5 +1,4 @@ -using Apollo.Components.Infrastructure.MessageBus; -using Apollo.Components.Infrastructure.Environment; +using Mythetech.Framework.Infrastructure.MessageBus; using Bunit; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; @@ -13,20 +12,16 @@ namespace Apollo.Test.Components.Infrastructure.MessageBus; public class MessageBusTests : TestContext { private IMessageBus _bus; - + public MessageBusTests() { Services.AddSingleton(); - var env = Substitute.For(); - env.Name.Returns("development"); - env.Version.Returns(new Version(0, 0)); - env.BaseAddress.Returns(string.Empty); _bus = new InMemoryMessageBus( this.Services, Substitute.For>(), - new CapturedEventState(), - env); + Enumerable.Empty(), + Enumerable.Empty()); Services.AddSingleton(_bus); } diff --git a/Apollo.Test/Components/Infrastructure/MessageBus/TestComponentConsumer.razor b/Apollo.Test/Components/Infrastructure/MessageBus/TestComponentConsumer.razor index e4776da..b92d0e0 100644 --- a/Apollo.Test/Components/Infrastructure/MessageBus/TestComponentConsumer.razor +++ b/Apollo.Test/Components/Infrastructure/MessageBus/TestComponentConsumer.razor @@ -1,4 +1,4 @@ -@inherits Apollo.Components.Infrastructure.MessageBus.ComponentConsumer +@inherits Mythetech.Framework.Infrastructure.MessageBus.ComponentConsumer

@Text

diff --git a/Apollo.Test/Components/Infrastructure/MessageBus/TestExceptionThrowingConsumer.razor b/Apollo.Test/Components/Infrastructure/MessageBus/TestExceptionThrowingConsumer.razor index 7dc53bd..20c6795 100644 --- a/Apollo.Test/Components/Infrastructure/MessageBus/TestExceptionThrowingConsumer.razor +++ b/Apollo.Test/Components/Infrastructure/MessageBus/TestExceptionThrowingConsumer.razor @@ -1,4 +1,4 @@ -@inherits Apollo.Components.Infrastructure.MessageBus.ComponentConsumer +@inherits Mythetech.Framework.Infrastructure.MessageBus.ComponentConsumer

@Text

diff --git a/Apollo.Test/Components/Settings/SettingsModelChangedTests.cs b/Apollo.Test/Components/Settings/SettingsModelChangedTests.cs new file mode 100644 index 0000000..40acd9c --- /dev/null +++ b/Apollo.Test/Components/Settings/SettingsModelChangedTests.cs @@ -0,0 +1,98 @@ +using Apollo.Components.Settings; +using Apollo.Components.Settings.Consumers; +using Apollo.Components.Settings.Events; +using Bunit; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Mythetech.Framework.Infrastructure.MessageBus; +using NSubstitute; +using Shouldly; +using Xunit; +using TestContext = Bunit.TestContext; + +namespace Apollo.Test.Components.Settings; + +public class SettingsModelChangedTests : TestContext +{ + private IMessageBus _bus; + + public SettingsModelChangedTests() + { + _bus = new InMemoryMessageBus( + Services, + Substitute.For>(), + Enumerable.Empty(), + Enumerable.Empty()); + Services.AddSingleton(_bus); + + // Register the converter that transforms SettingsModelChanged -> SettingsModelChanged + Services.AddSingleton(); + _bus.RegisterConsumerType(); + } + + [Fact(DisplayName = "When SettingsModelChanged is published, typed consumers receive SettingsModelChanged")] + public async Task TypedConsumer_Receives_SettingsModelChanged() + { + // Arrange + var consumer = new TestSettingsConsumer(); + _bus.Subscribe(consumer); + + // Also register it so the bus knows about this consumer type + Services.AddSingleton(consumer); + _bus.RegisterConsumerType, TestSettingsConsumer>(); + + var settings = new TestSettings { TestValue = "Hello World" }; + + // Act - publish the non-generic event (as SettingsProvider.ApplyStoredSettingsAsync does) + await _bus.PublishAsync(new SettingsModelChanged(typeof(TestSettings), settings)); + + // Assert - the typed consumer should have received the converted event + consumer.ReceivedModel.ShouldNotBeNull(); + consumer.ReceivedModel.TestValue.ShouldBe("Hello World"); + } + + [Fact(DisplayName = "Direct typed publish works")] + public async Task DirectTypedPublish_Works() + { + // Arrange + var consumer = new TestSettingsConsumer(); + _bus.Subscribe(consumer); + Services.AddSingleton(consumer); + _bus.RegisterConsumerType, TestSettingsConsumer>(); + + var settings = new TestSettings { TestValue = "Direct Test" }; + + // Act - publish directly as typed (this should work) + await _bus.PublishAsync(new SettingsModelChanged(settings)); + + // Assert + consumer.ReceivedModel.ShouldNotBeNull(); + consumer.ReceivedModel.TestValue.ShouldBe("Direct Test"); + } +} + +/// +/// Test settings model that extends SettingsBase +/// +public class TestSettings : SettingsBase +{ + public string TestValue { get; set; } = string.Empty; + + public override string Section => "Test"; + public override Type Type => typeof(TestSettings); + public override object Model => this; +} + +/// +/// Consumer that listens for SettingsModelChanged +/// +public class TestSettingsConsumer : IConsumer> +{ + public TestSettings? ReceivedModel { get; private set; } + + public Task Consume(SettingsModelChanged message) + { + ReceivedModel = message.Model; + return Task.CompletedTask; + } +} diff --git a/Apollo.Test/Components/TestMessageBus.cs b/Apollo.Test/Components/TestMessageBus.cs index b184200..d7bc130 100644 --- a/Apollo.Test/Components/TestMessageBus.cs +++ b/Apollo.Test/Components/TestMessageBus.cs @@ -1,23 +1,49 @@ -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; namespace Apollo.Test.Components; public class TestMessageBus : IMessageBus { - public async Task PublishAsync(TMessage message) where TMessage : class + public Task PublishAsync(TMessage message) where TMessage : class { - await Task.CompletedTask; + return Task.CompletedTask; } - public async Task PublishAsync(Type messageType, object message) + public Task PublishAsync(TMessage message, CancellationToken cancellationToken) where TMessage : class { - await Task.CompletedTask; + return Task.CompletedTask; + } + + public Task PublishAsync(TMessage message, PublishConfiguration configuration) where TMessage : class + { + return Task.CompletedTask; + } + + public Task SendAsync(TMessage message) + where TMessage : class + where TResponse : class + { + return Task.FromResult(default!); + } + + public Task SendAsync(TMessage message, QueryConfiguration configuration) + where TMessage : class + where TResponse : class + { + return Task.FromResult(default!); } public void RegisterConsumerType() where TMessage : class where TConsumer : IConsumer { } + public void RegisterQueryHandler() + where TMessage : class + where TResponse : class + where THandler : IQueryHandler + { + } + public void Subscribe(IConsumer consumer) where TMessage : class { } diff --git a/Apollo.Test/Components/Testing/TestingStateTests.cs b/Apollo.Test/Components/Testing/TestingStateTests.cs index d48d261..88969af 100644 --- a/Apollo.Test/Components/Testing/TestingStateTests.cs +++ b/Apollo.Test/Components/Testing/TestingStateTests.cs @@ -6,7 +6,7 @@ using Apollo.Compilation; using Apollo.Components.Analysis; using Apollo.Components.Hosting; -using Apollo.Components.Infrastructure.MessageBus; +using Mythetech.Framework.Infrastructure.MessageBus; using Apollo.Components.NuGet; using Apollo.Components.Solutions.Services; using Microsoft.CodeAnalysis; diff --git a/Directory.Packages.props b/Directory.Packages.props index f95bfa2..6ee7520 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -8,8 +8,8 @@ - - + +