public static IFuxionBuilder RabbitMQ(this IFuxionBuilder me, out Func <IServiceProvider, RabbitMQEventBus> builder, string exchangeName, string queueName, string connectionHost = "localhost", int connectionRetryCount = 5, int queueRetryCount = 5) { me.Services.AddSingleton <IRabbitMQPersistentConnection>(new DefaultRabbitMQPersistentConnection(new ConnectionFactory() { HostName = connectionHost }, connectionRetryCount)); builder = new Func <IServiceProvider, RabbitMQEventBus>(sp => { var bus = new RabbitMQEventBus( sp, sp.GetRequiredService <IRabbitMQPersistentConnection>(), sp.GetRequiredService <TypeKeyDirectory>(), exchangeName, queueName, queueRetryCount); // Esto se ejecutará al activar la instancia de RabbitMQEventBus // Suscribo los eventos externos. Se manejarán mediante EventHandlers igual que los eventos del propio bounded context foreach (var sub in sp.GetServices <EventSubscription>()) { bus.Subscribe(sub.EventType); } return(bus); }); me.Services.AddSingleton(builder); me.AddToAutoActivateList <RabbitMQEventBus>(); return(me); }
public static IFuxionBuilder Shell(this IFuxionBuilder me, Action <IShellBuilder> builder) { me.Services.AddSingleton <Cache>(); me.Services.AddSingleton <MenuManager>(); me.Services.AddSingleton <DockingManager>(); me.Services.AddSingleton <ShellViewModel>(); me.Services.AddSingleton <ShellWindow>(); me.AddToPostRegistrationList(serviceProvider => { foreach (var module in serviceProvider.GetServices <IModule>()) { module.Register(me.Services); } }); var shellBuilder = new ShellBuilder(me); me.AddToAutoActivateList <ShellWindow>(preAction: serviceProvider => { foreach (var module in serviceProvider.GetServices <IModule>()) { module.Initialize(serviceProvider); } }, postAction: (_, win) => { shellBuilder.ShellWindow = win; if (shellBuilder.ShowWindow) { win.Show(); } }); builder(shellBuilder); return(me); }