Skip to content
This repository has been archived by the owner on Aug 1, 2022. It is now read-only.

Commit

Permalink
refactor(Event): delete EventId、CreationTime、Add GetEventId、SetEventI…
Browse files Browse the repository at this point in the history
…d、GetCreationTime、SetCreationTime methods (#46)
  • Loading branch information
zhenlei520 authored Apr 28, 2022
1 parent fda18b3 commit 8c95d24
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
10 changes: 6 additions & 4 deletions src/Dispatcher/Masa.BuildingBlocks.Dispatcher.Events/IEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ namespace Masa.BuildingBlocks.Dispatcher.Events;

public interface IEvent
{
[JsonIgnore]
Guid Id { get; }
Guid GetEventId();

[JsonIgnore]
DateTime CreationTime { get; }
void SetEventId(Guid eventId);

DateTime GetCreationTime();

void SetCreationTime(DateTime creationTime);
}

public interface IEvent<TResult> : IEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class IntegrationEventLog

public Guid TransactionId { get; private set; } = Guid.Empty;

public string RowVersion { get;private set; }
public string RowVersion { get; private set; }

private IntegrationEventLog()
{
Expand All @@ -39,9 +39,9 @@ private IntegrationEventLog()

public IntegrationEventLog(IIntegrationEvent @event, Guid transactionId) : this()
{
EventId = @event.Id;
CreationTime = @event.CreationTime;
ModificationTime = @event.CreationTime;
EventId = @event.GetEventId();
CreationTime = @event.GetCreationTime();
ModificationTime = @event.GetCreationTime();
EventTypeName = @event.GetType().FullName!;
Content = System.Text.Json.JsonSerializer.Serialize((object)@event);
TransactionId = transactionId;
Expand All @@ -58,6 +58,8 @@ public void Initialize()
public IntegrationEventLog DeserializeJsonContent(Type type)
{
Event = (System.Text.Json.JsonSerializer.Deserialize(Content, type) as IIntegrationEvent)!;
Event?.SetEventId(this.EventId);
Event?.SetCreationTime(this.CreationTime);
return this;
}
}

0 comments on commit 8c95d24

Please sign in to comment.