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
  • Loading branch information
zhenlei520 committed Apr 28, 2022
1 parent fda18b3 commit 4396a7f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
13 changes: 6 additions & 7 deletions src/Dispatcher/Masa.BuildingBlocks.Dispatcher.Events/IEvent.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
// Copyright (c) MASA Stack All rights reserved.
// Licensed under the MIT License. See LICENSE.txt in the project root for license information.

namespace Masa.BuildingBlocks.Dispatcher.Events;

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

void SetEventId(Guid eventId);

DateTime GetCreationTime();

[JsonIgnore]
DateTime CreationTime { get; }
void SetCreationTime(DateTime creationTime);
}

public interface IEvent<TResult> : IEvent
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) MASA Stack All rights reserved.
// Licensed under the MIT License. See LICENSE.txt in the project root for license information.

namespace Masa.BuildingBlocks.Dispatcher.IntegrationEvents.Logs;

public class IntegrationEventLog
Expand Down Expand Up @@ -29,7 +26,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 +36,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 +55,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 4396a7f

Please sign in to comment.