Skip to content
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
131 changes: 65 additions & 66 deletions Shared.DomainDrivenDesign/EventSourcing/DomainEventRecord.cs
Original file line number Diff line number Diff line change
@@ -1,80 +1,79 @@
namespace Shared.DomainDrivenDesign.EventSourcing
{
using System;
using Newtonsoft.Json;
namespace Shared.DomainDrivenDesign.EventSourcing;

#region Others
using System;
using Newtonsoft.Json;

public record DomainEvent : IDomainEvent
{
#region Constructors
#region Others

/// <summary>
/// Initializes a new instance of the <see cref="DomainEventRecord" /> class.
/// </summary>
/// <param name="aggregateId">The aggregate identifier.</param>
/// <param name="eventId">The event identifier.</param>
public DomainEvent(Guid aggregateId,
Guid eventId) {
this.AggregateId = aggregateId;
this.EventId = eventId;
this.EventType = DomainHelper.GetEventTypeName(this.GetType());
}
public record DomainEvent : IDomainEvent
{
#region Constructors

#endregion
/// <summary>
/// Initializes a new instance of the <see cref="DomainEventRecord" /> class.
/// </summary>
/// <param name="aggregateId">The aggregate identifier.</param>
/// <param name="eventId">The event identifier.</param>
public DomainEvent(Guid aggregateId,
Guid eventId) {
this.AggregateId = aggregateId;
this.EventId = eventId;
this.EventType = DomainHelper.GetEventTypeName(this.GetType());
}

#region Properties
#endregion

/// <summary>
/// Gets the aggregate identifier.
/// </summary>
/// <value>
/// The aggregate identifier.
/// </value>
[JsonIgnore]
public Guid AggregateId { get; init; }
#region Properties

/// <summary>
/// Gets the aggregate version.
/// </summary>
/// <value>
/// The aggregate version.
/// </value>
[JsonIgnore]
public Int64 AggregateVersion { get; init; }
/// <summary>
/// Gets the aggregate identifier.
/// </summary>
/// <value>
/// The aggregate identifier.
/// </value>
[JsonIgnore]
public Guid AggregateId { get; init; }

/// <summary>
/// Gets the event identifier.
/// </summary>
/// <value>
/// The event identifier.
/// </value>
[JsonIgnore]
public Guid EventId { get; init; }
/// <summary>
/// Gets the aggregate version.
/// </summary>
/// <value>
/// The aggregate version.
/// </value>
[JsonIgnore]
public Int64 AggregateVersion { get; init; }

/// <summary>
/// Gets the event number.
/// </summary>
/// <value>
/// The event number.
/// </value>
[JsonIgnore]
public Int64 EventNumber { get; init; }
/// <summary>
/// Gets the event identifier.
/// </summary>
/// <value>
/// The event identifier.
/// </value>
[JsonIgnore]
public Guid EventId { get; init; }

/// <summary>
/// Gets the event timestamp.
/// </summary>
/// <value>
/// The event timestamp.
/// </value>
[JsonIgnore]
public DateTimeOffset EventTimestamp { get; init; }
/// <summary>
/// Gets the event number.
/// </summary>
/// <value>
/// The event number.
/// </value>
[JsonIgnore]
public Int64 EventNumber { get; init; }

[JsonIgnore]
public String EventType { get; init; }
/// <summary>
/// Gets the event timestamp.
/// </summary>
/// <value>
/// The event timestamp.
/// </value>
[JsonIgnore]
public DateTimeOffset EventTimestamp { get; init; }

#endregion
}
[JsonIgnore]
public String EventType { get; init; }

#endregion
}
}

#endregion
33 changes: 16 additions & 17 deletions Shared.DomainDrivenDesign/EventSourcing/DomainHelper.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
namespace Shared.DomainDrivenDesign.EventSourcing
namespace Shared.DomainDrivenDesign.EventSourcing;

using System;

/// <summary>
///
/// </summary>
public class DomainHelper
{
using System;
#region Methods

/// <summary>
///
/// Gets the name of the event type.
/// </summary>
public class DomainHelper
/// <param name="type">The type.</param>
/// <returns></returns>
internal static String GetEventTypeName(Type type)
{
#region Methods

/// <summary>
/// Gets the name of the event type.
/// </summary>
/// <param name="type">The type.</param>
/// <returns></returns>
internal static String GetEventTypeName(Type type)
{
return type.Name;
}

#endregion
return type.Name;
}

#endregion
}
97 changes: 48 additions & 49 deletions Shared.DomainDrivenDesign/EventSourcing/IDomainEvent.cs
Original file line number Diff line number Diff line change
@@ -1,58 +1,57 @@
namespace Shared.DomainDrivenDesign.EventSourcing
{
using System;
namespace Shared.DomainDrivenDesign.EventSourcing;

using System;

/// <summary>
///
/// </summary>
public interface IDomainEvent
{
/// <summary>
///
/// Gets the aggregate identifier.
/// </summary>
public interface IDomainEvent
{
/// <summary>
/// Gets the aggregate identifier.
/// </summary>
/// <value>
/// The aggregate identifier.
/// </value>
public Guid AggregateId { get; init; }
/// <value>
/// The aggregate identifier.
/// </value>
public Guid AggregateId { get; init; }

/// <summary>
/// Gets the aggregate version.
/// </summary>
/// <value>
/// The aggregate version.
/// </value>
public Int64 AggregateVersion { get; init; }
/// <summary>
/// Gets the aggregate version.
/// </summary>
/// <value>
/// The aggregate version.
/// </value>
public Int64 AggregateVersion { get; init; }

/// <summary>
/// Gets the event number.
/// </summary>
/// <value>
/// The event number.
/// </value>
public Int64 EventNumber { get; init; }
/// <summary>
/// Gets the event number.
/// </summary>
/// <value>
/// The event number.
/// </value>
public Int64 EventNumber { get; init; }

/// <summary>
/// Gets the type of the event.
/// </summary>
/// <value>
/// The type of the event.
/// </value>
public String EventType { get; init; }
/// <summary>
/// Gets the type of the event.
/// </summary>
/// <value>
/// The type of the event.
/// </value>
public String EventType { get; init; }

/// <summary>
/// Gets the event identifier.
/// </summary>
/// <value>
/// The event identifier.
/// </value>
public Guid EventId { get; init; }
/// <summary>
/// Gets the event identifier.
/// </summary>
/// <value>
/// The event identifier.
/// </value>
public Guid EventId { get; init; }

/// <summary>
/// Gets the event timestamp.
/// </summary>
/// <value>
/// The event timestamp.
/// </value>
public DateTimeOffset EventTimestamp { get; init; }
}
/// <summary>
/// Gets the event timestamp.
/// </summary>
/// <value>
/// The event timestamp.
/// </value>
public DateTimeOffset EventTimestamp { get; init; }
}
Loading
Loading