From 3c86ed09dc65c5e168ed0ac60d8a8d47db31ea5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Tue, 22 May 2018 05:21:31 +0300 Subject: [PATCH] Rename IAsyncEventHandler to IEventHandler --- .../Volo/Abp/EventBus/ActionEventHandler.cs | 4 ++-- .../Volo/Abp/EventBus/EventBus.cs | 6 +++--- .../Volo/Abp/EventBus/IAsyncEventHandler.cs | 17 ----------------- .../Volo/Abp/EventBus/IEventBus.cs | 4 ++-- .../Volo/Abp/EventBus/IEventHandler.cs | 17 ++++++++++++++++- .../Volo/Abp/EventBus/NullEventBus.cs | 4 ++-- .../EventBus/EventBus_MultipleHandle_Test.cs | 4 ++-- .../Abp/EventBus/MySimpleEventDataHandler.cs | 2 +- .../EventBus/MySimpleTransientEventHandler.cs | 2 +- 9 files changed, 29 insertions(+), 31 deletions(-) delete mode 100644 src/Volo.Abp.EventBus/Volo/Abp/EventBus/IAsyncEventHandler.cs diff --git a/src/Volo.Abp.EventBus/Volo/Abp/EventBus/ActionEventHandler.cs b/src/Volo.Abp.EventBus/Volo/Abp/EventBus/ActionEventHandler.cs index 69e834f5b0..32b41ec800 100644 --- a/src/Volo.Abp.EventBus/Volo/Abp/EventBus/ActionEventHandler.cs +++ b/src/Volo.Abp.EventBus/Volo/Abp/EventBus/ActionEventHandler.cs @@ -5,11 +5,11 @@ using Volo.Abp.DependencyInjection; namespace Volo.Abp.EventBus { /// - /// This event handler is an adapter to be able to use an action as implementation. + /// This event handler is an adapter to be able to use an action as implementation. /// /// Event type internal class ActionEventHandler : - IAsyncEventHandler, + IEventHandler, ITransientDependency { /// diff --git a/src/Volo.Abp.EventBus/Volo/Abp/EventBus/EventBus.cs b/src/Volo.Abp.EventBus/Volo/Abp/EventBus/EventBus.cs index 629946bf89..8b4fdf345b 100644 --- a/src/Volo.Abp.EventBus/Volo/Abp/EventBus/EventBus.cs +++ b/src/Volo.Abp.EventBus/Volo/Abp/EventBus/EventBus.cs @@ -70,7 +70,7 @@ namespace Volo.Abp.EventBus } /// - public IDisposable Register(IAsyncEventHandler handler) where TEvent : class + public IDisposable Register(IEventHandler handler) where TEvent : class { return Register(typeof(TEvent), handler); } @@ -133,7 +133,7 @@ namespace Volo.Abp.EventBus } /// - public void AsyncUnregister(IAsyncEventHandler handler) where TEvent : class + public void AsyncUnregister(IEventHandler handler) where TEvent : class { Unregister(typeof(TEvent), handler); } @@ -230,7 +230,7 @@ namespace Volo.Abp.EventBus { try { - var asyncHandlerType = typeof(IAsyncEventHandler<>).MakeGenericType(eventType); + var asyncHandlerType = typeof(IEventHandler<>).MakeGenericType(eventType); var method = asyncHandlerType.GetMethod( "HandleEventAsync", diff --git a/src/Volo.Abp.EventBus/Volo/Abp/EventBus/IAsyncEventHandler.cs b/src/Volo.Abp.EventBus/Volo/Abp/EventBus/IAsyncEventHandler.cs deleted file mode 100644 index d5336a578f..0000000000 --- a/src/Volo.Abp.EventBus/Volo/Abp/EventBus/IAsyncEventHandler.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Threading.Tasks; - -namespace Volo.Abp.EventBus -{ - /// - /// Defines an interface of a class that handles events asynchrounously of type . - /// - /// Event type to handle - public interface IAsyncEventHandler : IEventHandler - { - /// - /// Handler handles the event by implementing this method. - /// - /// Event data - Task HandleEventAsync(TEvent eventData); - } -} diff --git a/src/Volo.Abp.EventBus/Volo/Abp/EventBus/IEventBus.cs b/src/Volo.Abp.EventBus/Volo/Abp/EventBus/IEventBus.cs index 9fc334878d..993b094ee1 100644 --- a/src/Volo.Abp.EventBus/Volo/Abp/EventBus/IEventBus.cs +++ b/src/Volo.Abp.EventBus/Volo/Abp/EventBus/IEventBus.cs @@ -23,7 +23,7 @@ namespace Volo.Abp.EventBus /// /// Event type /// Object to handle the event - IDisposable Register(IAsyncEventHandler handler) + IDisposable Register(IEventHandler handler) where TEvent : class; /// @@ -73,7 +73,7 @@ namespace Volo.Abp.EventBus /// /// Event type /// Handler object that is registered before - void AsyncUnregister(IAsyncEventHandler handler) + void AsyncUnregister(IEventHandler handler) where TEvent : class; /// diff --git a/src/Volo.Abp.EventBus/Volo/Abp/EventBus/IEventHandler.cs b/src/Volo.Abp.EventBus/Volo/Abp/EventBus/IEventHandler.cs index 5c872d5832..ca3993c6bc 100644 --- a/src/Volo.Abp.EventBus/Volo/Abp/EventBus/IEventHandler.cs +++ b/src/Volo.Abp.EventBus/Volo/Abp/EventBus/IEventHandler.cs @@ -1,11 +1,26 @@ +using System.Threading.Tasks; + namespace Volo.Abp.EventBus { /// /// Undirect base interface for all event handlers. - /// Implement instead of this one. + /// Implement instead of this one. /// public interface IEventHandler { } + + /// + /// Defines an interface of a class that handles events asynchrounously of type . + /// + /// Event type to handle + public interface IEventHandler : IEventHandler + { + /// + /// Handler handles the event by implementing this method. + /// + /// Event data + Task HandleEventAsync(TEvent eventData); + } } \ No newline at end of file diff --git a/src/Volo.Abp.EventBus/Volo/Abp/EventBus/NullEventBus.cs b/src/Volo.Abp.EventBus/Volo/Abp/EventBus/NullEventBus.cs index f94c85a23f..0edbc06f79 100644 --- a/src/Volo.Abp.EventBus/Volo/Abp/EventBus/NullEventBus.cs +++ b/src/Volo.Abp.EventBus/Volo/Abp/EventBus/NullEventBus.cs @@ -17,7 +17,7 @@ namespace Volo.Abp.EventBus return NullDisposable.Instance; } - public IDisposable Register(IAsyncEventHandler handler) where TEvent : class + public IDisposable Register(IEventHandler handler) where TEvent : class { return NullDisposable.Instance; } @@ -47,7 +47,7 @@ namespace Volo.Abp.EventBus } - public void AsyncUnregister(IAsyncEventHandler handler) where TEvent : class + public void AsyncUnregister(IEventHandler handler) where TEvent : class { } diff --git a/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/EventBus_MultipleHandle_Test.cs b/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/EventBus_MultipleHandle_Test.cs index 12585902b8..78df6a6b40 100644 --- a/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/EventBus_MultipleHandle_Test.cs +++ b/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/EventBus_MultipleHandle_Test.cs @@ -28,8 +28,8 @@ namespace Volo.Abp.EventBus } public class MyEventHandler : - IAsyncEventHandler>, - IAsyncEventHandler> + IEventHandler>, + IEventHandler> { public int EntityChangedEventCount { get; set; } public int EntityCreatedEventCount { get; set; } diff --git a/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/MySimpleEventDataHandler.cs b/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/MySimpleEventDataHandler.cs index aa359a2394..700a68ef05 100644 --- a/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/MySimpleEventDataHandler.cs +++ b/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/MySimpleEventDataHandler.cs @@ -3,7 +3,7 @@ using Volo.Abp.DependencyInjection; namespace Volo.Abp.EventBus { - public class MySimpleEventDataHandler : IAsyncEventHandler, ISingletonDependency + public class MySimpleEventDataHandler : IEventHandler, ISingletonDependency { public int TotalData { get; private set; } diff --git a/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/MySimpleTransientEventHandler.cs b/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/MySimpleTransientEventHandler.cs index f013e2da46..be2b98026f 100644 --- a/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/MySimpleTransientEventHandler.cs +++ b/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/MySimpleTransientEventHandler.cs @@ -3,7 +3,7 @@ using System.Threading.Tasks; namespace Volo.Abp.EventBus { - public class MySimpleTransientEventHandler : IAsyncEventHandler, IDisposable + public class MySimpleTransientEventHandler : IEventHandler, IDisposable { public static int HandleCount { get; set; }