Browse Source

Rename IAsyncEventHandler to IEventHandler

pull/279/head
Halil İbrahim Kalkan 8 years ago
parent
commit
3c86ed09dc
  1. 4
      src/Volo.Abp.EventBus/Volo/Abp/EventBus/ActionEventHandler.cs
  2. 6
      src/Volo.Abp.EventBus/Volo/Abp/EventBus/EventBus.cs
  3. 17
      src/Volo.Abp.EventBus/Volo/Abp/EventBus/IAsyncEventHandler.cs
  4. 4
      src/Volo.Abp.EventBus/Volo/Abp/EventBus/IEventBus.cs
  5. 17
      src/Volo.Abp.EventBus/Volo/Abp/EventBus/IEventHandler.cs
  6. 4
      src/Volo.Abp.EventBus/Volo/Abp/EventBus/NullEventBus.cs
  7. 4
      test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/EventBus_MultipleHandle_Test.cs
  8. 2
      test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/MySimpleEventDataHandler.cs
  9. 2
      test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/MySimpleTransientEventHandler.cs

4
src/Volo.Abp.EventBus/Volo/Abp/EventBus/ActionEventHandler.cs

@ -5,11 +5,11 @@ using Volo.Abp.DependencyInjection;
namespace Volo.Abp.EventBus
{
/// <summary>
/// This event handler is an adapter to be able to use an action as <see cref="IAsyncEventHandler{TEventData}"/> implementation.
/// This event handler is an adapter to be able to use an action as <see cref="IEventHandler{TEvent}"/> implementation.
/// </summary>
/// <typeparam name="TEvent">Event type</typeparam>
internal class ActionEventHandler<TEvent> :
IAsyncEventHandler<TEvent>,
IEventHandler<TEvent>,
ITransientDependency
{
/// <summary>

6
src/Volo.Abp.EventBus/Volo/Abp/EventBus/EventBus.cs

@ -70,7 +70,7 @@ namespace Volo.Abp.EventBus
}
/// <inheritdoc/>
public IDisposable Register<TEvent>(IAsyncEventHandler<TEvent> handler) where TEvent : class
public IDisposable Register<TEvent>(IEventHandler<TEvent> handler) where TEvent : class
{
return Register(typeof(TEvent), handler);
}
@ -133,7 +133,7 @@ namespace Volo.Abp.EventBus
}
/// <inheritdoc/>
public void AsyncUnregister<TEvent>(IAsyncEventHandler<TEvent> handler) where TEvent : class
public void AsyncUnregister<TEvent>(IEventHandler<TEvent> 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",

17
src/Volo.Abp.EventBus/Volo/Abp/EventBus/IAsyncEventHandler.cs

@ -1,17 +0,0 @@
using System.Threading.Tasks;
namespace Volo.Abp.EventBus
{
/// <summary>
/// Defines an interface of a class that handles events asynchrounously of type <see cref="IAsyncEventHandler{TEventData}"/>.
/// </summary>
/// <typeparam name="TEvent">Event type to handle</typeparam>
public interface IAsyncEventHandler<in TEvent> : IEventHandler
{
/// <summary>
/// Handler handles the event by implementing this method.
/// </summary>
/// <param name="eventData">Event data</param>
Task HandleEventAsync(TEvent eventData);
}
}

4
src/Volo.Abp.EventBus/Volo/Abp/EventBus/IEventBus.cs

@ -23,7 +23,7 @@ namespace Volo.Abp.EventBus
/// </summary>
/// <typeparam name="TEvent">Event type</typeparam>
/// <param name="handler">Object to handle the event</param>
IDisposable Register<TEvent>(IAsyncEventHandler<TEvent> handler)
IDisposable Register<TEvent>(IEventHandler<TEvent> handler)
where TEvent : class;
/// <summary>
@ -73,7 +73,7 @@ namespace Volo.Abp.EventBus
/// </summary>
/// <typeparam name="TEvent">Event type</typeparam>
/// <param name="handler">Handler object that is registered before</param>
void AsyncUnregister<TEvent>(IAsyncEventHandler<TEvent> handler)
void AsyncUnregister<TEvent>(IEventHandler<TEvent> handler)
where TEvent : class;
/// <summary>

17
src/Volo.Abp.EventBus/Volo/Abp/EventBus/IEventHandler.cs

@ -1,11 +1,26 @@
using System.Threading.Tasks;
namespace Volo.Abp.EventBus
{
/// <summary>
/// Undirect base interface for all event handlers.
/// Implement <see cref="IAsyncEventHandler{TEventData}"/> instead of this one.
/// Implement <see cref="IEventHandler{TEvent}"/> instead of this one.
/// </summary>
public interface IEventHandler
{
}
/// <summary>
/// Defines an interface of a class that handles events asynchrounously of type <see cref="IEventHandler{TEvent}"/>.
/// </summary>
/// <typeparam name="TEvent">Event type to handle</typeparam>
public interface IEventHandler<in TEvent> : IEventHandler
{
/// <summary>
/// Handler handles the event by implementing this method.
/// </summary>
/// <param name="eventData">Event data</param>
Task HandleEventAsync(TEvent eventData);
}
}

4
src/Volo.Abp.EventBus/Volo/Abp/EventBus/NullEventBus.cs

@ -17,7 +17,7 @@ namespace Volo.Abp.EventBus
return NullDisposable.Instance;
}
public IDisposable Register<TEvent>(IAsyncEventHandler<TEvent> handler) where TEvent : class
public IDisposable Register<TEvent>(IEventHandler<TEvent> handler) where TEvent : class
{
return NullDisposable.Instance;
}
@ -47,7 +47,7 @@ namespace Volo.Abp.EventBus
}
public void AsyncUnregister<TEvent>(IAsyncEventHandler<TEvent> handler) where TEvent : class
public void AsyncUnregister<TEvent>(IEventHandler<TEvent> handler) where TEvent : class
{
}

4
test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/EventBus_MultipleHandle_Test.cs

@ -28,8 +28,8 @@ namespace Volo.Abp.EventBus
}
public class MyEventHandler :
IAsyncEventHandler<EntityChangedEventData<MyEntity>>,
IAsyncEventHandler<EntityCreatedEventData<MyEntity>>
IEventHandler<EntityChangedEventData<MyEntity>>,
IEventHandler<EntityCreatedEventData<MyEntity>>
{
public int EntityChangedEventCount { get; set; }
public int EntityCreatedEventCount { get; set; }

2
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<MySimpleEventData>, ISingletonDependency
public class MySimpleEventDataHandler : IEventHandler<MySimpleEventData>, ISingletonDependency
{
public int TotalData { get; private set; }

2
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<MySimpleEventData>, IDisposable
public class MySimpleTransientEventHandler : IEventHandler<MySimpleEventData>, IDisposable
{
public static int HandleCount { get; set; }

Loading…
Cancel
Save