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

refactor(Event): delete EventId、CreationTime、Add GetEventId、SetEventId、GetCreationTime、SetCreationTime methods #46

Merged
merged 1 commit into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}