diff --git a/framework/src/Volo.Abp.EventBus.Distributed.RabbitMQ/Volo/Abp/EventBus/Distributed/RabbitMq/RabbitMqDistributedEventBus.cs b/framework/src/Volo.Abp.EventBus.Distributed.RabbitMQ/Volo/Abp/EventBus/Distributed/RabbitMq/RabbitMqDistributedEventBus.cs index 4bf615a998..99173ee333 100644 --- a/framework/src/Volo.Abp.EventBus.Distributed.RabbitMQ/Volo/Abp/EventBus/Distributed/RabbitMq/RabbitMqDistributedEventBus.cs +++ b/framework/src/Volo.Abp.EventBus.Distributed.RabbitMQ/Volo/Abp/EventBus/Distributed/RabbitMq/RabbitMqDistributedEventBus.cs @@ -124,6 +124,11 @@ namespace Volo.Abp.EventBus.Distributed.RabbitMq channel.BasicAck(ea.DeliveryTag, multiple: false); } + public IDisposable Subscribe(IDistributedEventHandler handler) where TEvent : class + { + return Subscribe(typeof(TEvent), handler); + } + public override IDisposable Subscribe(Type eventType, IEventHandlerFactory factory) { var handlerFactories = GetOrCreateHandlerFactories(eventType); diff --git a/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/IDistributedEventBus.cs b/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/IDistributedEventBus.cs index 88cbf721b3..e406f7069b 100644 --- a/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/IDistributedEventBus.cs +++ b/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/IDistributedEventBus.cs @@ -1,7 +1,16 @@ -namespace Volo.Abp.EventBus.Distributed +using System; + +namespace Volo.Abp.EventBus.Distributed { public interface IDistributedEventBus : IEventBus { - + /// + /// Registers to an event. + /// Same (given) instance of the handler is used for all event occurrences. + /// + /// Event type + /// Object to handle the event + IDisposable Subscribe(IDistributedEventHandler handler) + where TEvent : class; } } diff --git a/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/LocalDistributedEventBus.cs b/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/LocalDistributedEventBus.cs index cfbf7b0211..c7b0cef7b1 100644 --- a/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/LocalDistributedEventBus.cs +++ b/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/LocalDistributedEventBus.cs @@ -48,6 +48,12 @@ namespace Volo.Abp.EventBus.Distributed } } + /// + public virtual IDisposable Subscribe(IDistributedEventHandler handler) where TEvent : class + { + return Subscribe(typeof(TEvent), handler); + } + public IDisposable Subscribe(Func action) where TEvent : class { return _localEventBus.Subscribe(action); diff --git a/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/NullDistributedEventBus.cs b/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/NullDistributedEventBus.cs index 8df6455d52..cfec832893 100644 --- a/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/NullDistributedEventBus.cs +++ b/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/NullDistributedEventBus.cs @@ -17,7 +17,7 @@ namespace Volo.Abp.EventBus.Distributed return NullDisposable.Instance; } - public IDisposable Subscribe(ILocalEventHandler handler) where TEvent : class + public IDisposable Subscribe(IDistributedEventHandler handler) where TEvent : class { return NullDisposable.Instance; } diff --git a/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/EventBusBase.cs b/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/EventBusBase.cs index 04f5b0f79d..c700f46532 100644 --- a/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/EventBusBase.cs +++ b/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/EventBusBase.cs @@ -18,12 +18,6 @@ namespace Volo.Abp.EventBus return Subscribe(typeof(TEvent), new ActionEventHandler(action)); } - /// - public virtual IDisposable Subscribe(ILocalEventHandler handler) where TEvent : class - { - return Subscribe(typeof(TEvent), handler); - } - /// public virtual IDisposable Subscribe() where TEvent : class diff --git a/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/IEventBus.cs b/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/IEventBus.cs index 0ffd4cad91..4526c1f3b4 100644 --- a/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/IEventBus.cs +++ b/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/IEventBus.cs @@ -31,15 +31,6 @@ namespace Volo.Abp.EventBus IDisposable Subscribe(Func action) where TEvent : class; - /// - /// Registers to an event. - /// Same (given) instance of the handler is used for all event occurrences. - /// - /// Event type - /// Object to handle the event - IDisposable Subscribe(ILocalEventHandler handler) - where TEvent : class; - /// /// Registers to an event. /// A new instance of object is created for every event occurrence. diff --git a/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Local/ILocalEventBus.cs b/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Local/ILocalEventBus.cs index 7e81a363af..5640a4c17b 100644 --- a/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Local/ILocalEventBus.cs +++ b/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Local/ILocalEventBus.cs @@ -1,3 +1,5 @@ +using System; + namespace Volo.Abp.EventBus.Local { /// @@ -5,6 +7,13 @@ namespace Volo.Abp.EventBus.Local /// public interface ILocalEventBus : IEventBus { - + /// + /// Registers to an event. + /// Same (given) instance of the handler is used for all event occurrences. + /// + /// Event type + /// Object to handle the event + IDisposable Subscribe(ILocalEventHandler handler) + where TEvent : class; } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Local/LocalEventBus.cs b/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Local/LocalEventBus.cs index 31238961ae..ae1041c9e2 100644 --- a/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Local/LocalEventBus.cs +++ b/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Local/LocalEventBus.cs @@ -63,6 +63,12 @@ namespace Volo.Abp.EventBus.Local } } + /// + public virtual IDisposable Subscribe(ILocalEventHandler handler) where TEvent : class + { + return Subscribe(typeof(TEvent), handler); + } + /// public override IDisposable Subscribe(Type eventType, IEventHandlerFactory factory) {