Exemple #1
0
        public static SimpleEventBusMsDIBuilder AddRabbitMQ(this SimpleEventBusMsDIBuilder builder,
                                                            EventReceivedFunc configEventReceived = null,
                                                            Func <IServiceProvider, IEventSerializer <byte[]> > configSerializer = null,
                                                            Func <ConnectionFactory> configConnectionFactory = null)
        {
            builder.Config(services =>
            {
                if (configEventReceived != null)
                {
                    services.TryAddSingleton(configEventReceived);
                }
                if (configSerializer != null)
                {
                    services.TryAddSingleton(_ => configSerializer(_));
                }
                if (configConnectionFactory != null)
                {
                    services.TryAddSingleton(_ => configConnectionFactory());
                }

                services.TryAddSingleton <IEventNameTypeResolver, DefaultEventNameTypeResolver>();
                services.TryAddSingleton <IEventBus, RabbitMQEventBus>();
                services.TryAddSingleton <IRabbitMQConnection, DefaultRabbitMQConnection>();
            });
            return(builder);
        }
Exemple #2
0
 public static SimpleEventBusMsDIBuilder AddInMemory(this SimpleEventBusMsDIBuilder builder, Action <ISubscriptionsManager> config = null)
 {
     builder.AddInMemorySubscriptionsManager(config);
     builder.Config(services =>
     {
         services.TryAddScoped <IPublisher, InMemoryPublisher>();
         services.TryAddScoped <IEventBus, InMemoryEventBus>();
     });
     return(builder);
 }
Exemple #3
0
 public static SimpleEventBusMsDIBuilder AddInMemorySubscriptionsManager(this SimpleEventBusMsDIBuilder builder, Action <ISubscriptionsManager> config = null)
 {
     builder.Config(services =>
     {
         services.TryAddSingleton <ISubscriptionsManager>(_ =>
         {
             var smr = new InMemorySubscriptionsManager();
             config?.Invoke(smr);
             return(smr);
         });
     });
     return(builder);
 }