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