Skip to content

Commit dbe68e4

Browse files
Merge pull request #139 from TransactionProcessing/task/#130_addcodefactor
Code format to trigger PR
2 parents a132ea6 + a691451 commit dbe68e4

2 files changed

Lines changed: 17 additions & 19 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
## Build Status
44
[![Last Release Status Badge](https://github.com/StuartFerguson/Shared/workflows/Release/badge.svg)](https://github.com/StuartFerguson/Shared/workflows/Release/badge.svg)
55

6+
## CodeFactor Code Quality
7+
[![CodeFactor](https://www.codefactor.io/repository/github/transactionprocessing/shared/badge)](https://www.codefactor.io/repository/github/transactionprocessing/shared)
8+
69
## Nuget Versions
710
|||
811
| --- | --- |

Shared.EventStore/Aggregate/Aggregate.cs

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ public abstract class Aggregate
1414
/// <summary>
1515
/// Initializes a new instance of the <see cref="Aggregate" /> class.
1616
/// </summary>
17-
protected Aggregate()
18-
{
17+
protected Aggregate() {
1918
this.EventHistory = new Dictionary<Guid, IDomainEvent>();
2019
this.PendingEvents = new List<IDomainEvent>();
2120
this.Version = -1L;
@@ -41,6 +40,14 @@ protected Aggregate()
4140
/// </value>
4241
public AggregateVersion Version { get; internal set; }
4342

43+
/// <summary>
44+
/// Gets the number of historical events.
45+
/// </summary>
46+
/// <value>
47+
/// The number of historical events.
48+
/// </value>
49+
protected Int64 NumberOfHistoricalEvents => this.EventHistory.Count;
50+
4451
/// <summary>
4552
/// Gets or sets the event history.
4653
/// </summary>
@@ -65,46 +72,34 @@ protected Aggregate()
6572
/// Applies the and append.
6673
/// </summary>
6774
/// <param name="domainEvent">The domain event.</param>
68-
public void ApplyAndAppend(IDomainEvent domainEvent)
69-
{
75+
public void ApplyAndAppend(IDomainEvent domainEvent) {
7076
if (domainEvent == null) return; //Silently handled
7177

72-
try
73-
{
78+
try {
7479
if (this.IsEventDuplicate(domainEvent.EventId))
7580
return;
7681

7782
this.PlayEvent(domainEvent);
7883
this.PendingEvents.Add(domainEvent);
7984
}
80-
catch (Exception e)
81-
{
85+
catch(Exception e) {
8286
Exception ex = new Exception($"Failed to apply event {domainEvent.EventType} to Aggregate {this.GetType().Name}", e);
8387

8488
throw ex;
8589
}
8690
}
8791

88-
public Object GetAggregateMetadata()
89-
{
92+
public Object GetAggregateMetadata() {
9093
return this.GetMetadata();
9194
}
9295

93-
protected abstract Object GetMetadata();
94-
9596
/// <summary>
9697
/// Plays the event.
9798
/// </summary>
9899
/// <param name="domainEvent">The domain event.</param>
99100
public abstract void PlayEvent(IDomainEvent domainEvent);
100101

101-
/// <summary>
102-
/// Gets the number of historical events.
103-
/// </summary>
104-
/// <value>
105-
/// The number of historical events.
106-
/// </value>
107-
protected Int64 NumberOfHistoricalEvents => EventHistory.Count;
102+
protected abstract Object GetMetadata();
108103

109104
#endregion
110105
}

0 commit comments

Comments
 (0)