-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
54694ea
commit c745a6b
Showing
8 changed files
with
166 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Eventify | ||
{ | ||
/// <summary> | ||
/// Contains event information which gets passed to | ||
/// <see cref="IEventPublisherListener.OnEventPublished"/> | ||
/// after publishing event | ||
/// </summary> | ||
public class EventPublishedContext : EventPublishingContext | ||
{ | ||
/// <summary> | ||
/// Represents the does exception occurred while publishing event or not | ||
/// </summary> | ||
public bool IsFaulted => EventExceptionList.Count != 0; | ||
|
||
/// <summary> | ||
/// This will contain occurred exception information for further logging or processing | ||
/// </summary> | ||
public List<Exception> EventExceptionList { get; } | ||
|
||
/// <summary> | ||
/// Type of handler in which <see cref="Exception"/> has been thrown-ed | ||
/// </summary> | ||
public List<Type> ExceptionHandlerTypeList { get; } | ||
|
||
internal EventPublishedContext(Guid eventId, string eventName, Type eventType) : base(eventId, eventName, eventType) | ||
{ | ||
EventExceptionList = new List<Exception>(); | ||
ExceptionHandlerTypeList = new List<Type>(); | ||
} | ||
|
||
internal void SetException(Exception e, Type handlerExceptionType) | ||
{ | ||
EventExceptionList.Add(e); | ||
ExceptionHandlerTypeList.Add(handlerExceptionType); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System; | ||
|
||
namespace Eventify | ||
{ | ||
/// <summary> | ||
/// Contains event information which gets passed to | ||
/// <see cref="IEventPublisherListener.OnEventPublishing"/> | ||
/// before publishing event | ||
/// </summary> | ||
public class EventPublishingContext | ||
{ | ||
protected object _eventData; | ||
|
||
/// <summary> | ||
/// Id of currently published <see cref="Event"/> | ||
/// </summary> | ||
public Guid EventId { get; } | ||
|
||
/// <summary> | ||
/// Name of currently publishing <see cref="Event"/> | ||
/// </summary> | ||
public string EventName { get; } | ||
|
||
/// <summary> | ||
/// Type of <see cref="Event"/> class | ||
/// </summary> | ||
public Type EventType { get; } | ||
|
||
internal EventPublishingContext(Guid eventId, string eventName, Type eventType) | ||
{ | ||
EventId = eventId; | ||
EventName = eventName; | ||
EventType = eventType; | ||
} | ||
|
||
public void SetEventData<T>(T eventData) | ||
{ | ||
_eventData = eventData; | ||
} | ||
|
||
public T GetEventData<T>() | ||
{ | ||
return (T)_eventData; | ||
} | ||
|
||
public dynamic GetEventData() | ||
{ | ||
return _eventData; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
namespace Eventify | ||
{ | ||
/// <summary> | ||
/// Contract for Event listeners | ||
/// </summary> | ||
public interface IEventPublisherListener | ||
{ | ||
/// <summary> | ||
/// Gets executed before publishing an <see cref="Event"/> | ||
/// </summary> | ||
/// <param name="context">Context containing current <see cref="Event"/> information</param> | ||
void OnEventPublishing(EventPublishingContext context); | ||
|
||
/// <summary> | ||
/// Gets executed after publishing an <see cref="Event"/> | ||
/// </summary> | ||
/// <param name="context">Context containing event execution information</param> | ||
void OnEventPublished(EventPublishedContext context); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters