diff --git a/samples/DFlow.Samples/DFlow.Samples.csproj b/samples/DFlow.Samples/DFlow.Samples.csproj
index 7087d61..efc7149 100644
--- a/samples/DFlow.Samples/DFlow.Samples.csproj
+++ b/samples/DFlow.Samples/DFlow.Samples.csproj
@@ -13,10 +13,10 @@
+
+
-
-
diff --git a/samples/DFlow.Samples/Domain/Aggregates/Events/UserAddedEvent.cs b/samples/DFlow.Samples/Domain/Aggregates/Events/UserAddedEvent.cs
index f5dda5a..8e96884 100644
--- a/samples/DFlow.Samples/Domain/Aggregates/Events/UserAddedEvent.cs
+++ b/samples/DFlow.Samples/Domain/Aggregates/Events/UserAddedEvent.cs
@@ -7,7 +7,7 @@
using System;
using DFlow.Domain.BusinessObjects;
-using DFlow.Domain.DomainEvents;
+using DFlow.Domain.Events.DomainEvents;
using DFlow.Samples.Domain.BusinessObjects;
namespace DFlow.Samples.Domain.Aggregates.Events
diff --git a/samples/DFlow.Samples/Domain/Aggregates/UserEntityBasedAggregationRoot.cs b/samples/DFlow.Samples/Domain/Aggregates/UserEntityBasedAggregationRoot.cs
index d4e80d0..bc95d37 100644
--- a/samples/DFlow.Samples/Domain/Aggregates/UserEntityBasedAggregationRoot.cs
+++ b/samples/DFlow.Samples/Domain/Aggregates/UserEntityBasedAggregationRoot.cs
@@ -4,14 +4,14 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
-using DFlow.Domain.Aggregates;
using DFlow.Domain.BusinessObjects;
+using DFlow.Domain.Events;
using DFlow.Samples.Domain.Aggregates.Events;
using DFlow.Samples.Domain.BusinessObjects;
namespace DFlow.Samples.Domain.Aggregates
{
- public sealed class UserEntityBasedAggregationRoot : ObjectBasedAggregationRoot
+ public sealed class UserEntityBasedAggregationRoot : ObjectBasedAggregationRootWithEvents
{
private UserEntityBasedAggregationRoot(User user)
diff --git a/src/DFlow.Domain/Aggregates/EventBasedAggregationRoot.cs b/src/DFlow.Domain.Events/Aggregates/EventBasedAggregationRoot.cs
similarity index 93%
rename from src/DFlow.Domain/Aggregates/EventBasedAggregationRoot.cs
rename to src/DFlow.Domain.Events/Aggregates/EventBasedAggregationRoot.cs
index 50444c8..3d94a5c 100644
--- a/src/DFlow.Domain/Aggregates/EventBasedAggregationRoot.cs
+++ b/src/DFlow.Domain.Events/Aggregates/EventBasedAggregationRoot.cs
@@ -6,11 +6,12 @@
using System.Collections.Generic;
using System.Collections.Immutable;
+using DFlow.Domain.Aggregates;
using DFlow.Domain.BusinessObjects;
-using DFlow.Domain.Events;
+using DFlow.Domain.Events.BusinessObjects;
using DFlow.Domain.Validation;
-namespace DFlow.Domain.Aggregates
+namespace DFlow.Domain.Events.Aggregates
{
public class EventBasedAggregationRoot: BaseValidation, IChangeSet>
{
@@ -45,10 +46,9 @@ protected void Apply(IDomainEvent domainEvent)
_currentStream.Add(domainEvent);
}
- //Need to check tath
+
protected void Raise(IDomainEvent @event)
{
- //this isint right
_changes.Add(@event);
}
diff --git a/src/DFlow.Domain/BusinessObjects/EventStream.cs b/src/DFlow.Domain.Events/BusinessObjects/EventStream.cs
similarity index 74%
rename from src/DFlow.Domain/BusinessObjects/EventStream.cs
rename to src/DFlow.Domain.Events/BusinessObjects/EventStream.cs
index 64c2da3..01390f4 100644
--- a/src/DFlow.Domain/BusinessObjects/EventStream.cs
+++ b/src/DFlow.Domain.Events/BusinessObjects/EventStream.cs
@@ -1,20 +1,26 @@
+// Copyright (C) 2022 Road to Agility
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at https://mozilla.org/MPL/2.0/.
+
using System.Collections.Generic;
using System.Collections.Immutable;
-using DFlow.Domain.Events;
-using DFlow.Domain.Validation;
+using DFlow.Domain.BusinessObjects;
-namespace DFlow.Domain.BusinessObjects
+namespace DFlow.Domain.Events.BusinessObjects
{
public class EventStream: BaseEntity
{
- private EventStream(TEntityId aggregateId, AggregationName aggregationName, VersionId version, IImmutableList events)
- :base(aggregateId, version)
+ private EventStream(TEntityId aggregateId, AggregationName aggregationName
+ , VersionId version, IImmutableList events)
+ : base(aggregateId, version)
{
AggregationId = aggregateId;
Name = aggregationName;
Events = events;
}
-
+
public TEntityId AggregationId { get; }
public AggregationName Name { get; }
public IImmutableList Events { get; }
diff --git a/src/DFlow.Domain.Events/DFlow.Domain.Events.csproj b/src/DFlow.Domain.Events/DFlow.Domain.Events.csproj
index 8026629..4848228 100644
--- a/src/DFlow.Domain.Events/DFlow.Domain.Events.csproj
+++ b/src/DFlow.Domain.Events/DFlow.Domain.Events.csproj
@@ -11,4 +11,8 @@
true
+
+
+
+
diff --git a/src/DFlow.Domain/DomainEvents/AggregateAddedDomainEvent.cs b/src/DFlow.Domain.Events/DomainEvents/AggregateAddedDomainEvent.cs
similarity index 87%
rename from src/DFlow.Domain/DomainEvents/AggregateAddedDomainEvent.cs
rename to src/DFlow.Domain.Events/DomainEvents/AggregateAddedDomainEvent.cs
index 2f6ea68..3a7d295 100644
--- a/src/DFlow.Domain/DomainEvents/AggregateAddedDomainEvent.cs
+++ b/src/DFlow.Domain.Events/DomainEvents/AggregateAddedDomainEvent.cs
@@ -1,4 +1,4 @@
-// Copyright (C) 2020 Road to Agility
+// Copyright (C) 2022 Road to Agility
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -7,7 +7,7 @@
using System;
using DFlow.Domain.BusinessObjects;
-namespace DFlow.Domain.DomainEvents
+namespace DFlow.Domain.Events.DomainEvents
{
public class AggregateAddedDomainEvent : DomainEvent
{
diff --git a/src/DFlow.Domain/DomainEvents/DomainEvent.cs b/src/DFlow.Domain.Events/DomainEvents/DomainEvent.cs
similarity index 84%
rename from src/DFlow.Domain/DomainEvents/DomainEvent.cs
rename to src/DFlow.Domain.Events/DomainEvents/DomainEvent.cs
index 4200349..7a3f427 100644
--- a/src/DFlow.Domain/DomainEvents/DomainEvent.cs
+++ b/src/DFlow.Domain.Events/DomainEvents/DomainEvent.cs
@@ -1,4 +1,4 @@
-// Copyright (C) 2020 Road to Agility
+// Copyright (C) 2022 Road to Agility
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -6,9 +6,8 @@
using System;
using DFlow.Domain.BusinessObjects;
-using DFlow.Domain.Events;
-namespace DFlow.Domain.DomainEvents
+namespace DFlow.Domain.Events.DomainEvents
{
public class DomainEvent : IDomainEvent
{
diff --git a/src/DFlow.Domain.Events/IDomainEventBusAsync.cs b/src/DFlow.Domain.Events/IDomainEventBusAsync.cs
deleted file mode 100644
index 4f4400d..0000000
--- a/src/DFlow.Domain.Events/IDomainEventBusAsync.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright (C) 2020 Road to Agility
-//
-// This Source Code Form is subject to the terms of the Mozilla Public
-// License, v. 2.0. If a copy of the MPL was not distributed with this
-// file, You can obtain one at https://mozilla.org/MPL/2.0/.
-
-using System.Threading;
-using System.Threading.Tasks;
-
-namespace DFlow.Domain.Events
-{
- public interface IDomainEventBusAsync
- {
- Task PublishAsync(TEvent request, CancellationToken cancellationToken);
-
- Task SendAsync(TRequest request, CancellationToken cancellationToken);
- }
-}
\ No newline at end of file
diff --git a/src/DFlow.Domain.Events/IDomainEventHandlerAsync.cs b/src/DFlow.Domain.Events/IDomainEvents.cs
similarity index 59%
rename from src/DFlow.Domain.Events/IDomainEventHandlerAsync.cs
rename to src/DFlow.Domain.Events/IDomainEvents.cs
index a7f4c0b..32e4255 100644
--- a/src/DFlow.Domain.Events/IDomainEventHandlerAsync.cs
+++ b/src/DFlow.Domain.Events/IDomainEvents.cs
@@ -4,13 +4,12 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
-using System.Threading;
-using System.Threading.Tasks;
+using System.Collections.Generic;
namespace DFlow.Domain.Events
{
- public interface IDomainEventHandlerAsync
+ public interface IDomainEvents
{
- Task HandleAsync(TDomainEvent @event, CancellationToken cancellationToken);
+ IReadOnlyList GetEvents();
}
}
\ No newline at end of file
diff --git a/src/DFlow.Domain.Events/ObjectBasedAggregationRootWithEvents.cs b/src/DFlow.Domain.Events/ObjectBasedAggregationRootWithEvents.cs
new file mode 100644
index 0000000..86a7ab9
--- /dev/null
+++ b/src/DFlow.Domain.Events/ObjectBasedAggregationRootWithEvents.cs
@@ -0,0 +1,29 @@
+// Copyright (C) 2020 Road to Agility
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at https://mozilla.org/MPL/2.0/.
+
+using System.Collections.Generic;
+using System.Collections.Immutable;
+using DFlow.Domain.Aggregates;
+using DFlow.Domain.BusinessObjects;
+
+namespace DFlow.Domain.Events
+{
+ public abstract class ObjectBasedAggregationRootWithEvents:
+ ObjectBasedAggregationRoot where TChange:BaseEntity
+ {
+ private readonly IList _changes = new List();
+
+ protected void Raise(IDomainEvent @event)
+ {
+ _changes.Add(@event);
+ }
+
+ public IReadOnlyList GetEvents()
+ {
+ return _changes.ToImmutableList();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/DFlow.Domain/Aggregates/IChangeSet.cs b/src/DFlow.Domain/Aggregates/IChangeSet.cs
index c05d653..03dec03 100644
--- a/src/DFlow.Domain/Aggregates/IChangeSet.cs
+++ b/src/DFlow.Domain/Aggregates/IChangeSet.cs
@@ -4,14 +4,10 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
-using System.Collections.Generic;
-using DFlow.Domain.Events;
-
namespace DFlow.Domain.Aggregates
{
public interface IChangeSet
{
TChange GetChange();
- IReadOnlyList GetEvents();
}
}
\ No newline at end of file
diff --git a/src/DFlow.Domain/Aggregates/ObjectBasedAggregationRoot.cs b/src/DFlow.Domain/Aggregates/ObjectBasedAggregationRoot.cs
index ffa8718..ef5a2d8 100644
--- a/src/DFlow.Domain/Aggregates/ObjectBasedAggregationRoot.cs
+++ b/src/DFlow.Domain/Aggregates/ObjectBasedAggregationRoot.cs
@@ -4,10 +4,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
-using System.Collections.Generic;
-using System.Collections.Immutable;
using DFlow.Domain.BusinessObjects;
-using DFlow.Domain.Events;
using DFlow.Domain.Validation;
namespace DFlow.Domain.Aggregates
@@ -16,26 +13,15 @@ public abstract class ObjectBasedAggregationRoot:BaseValidat
IChangeSet where TChange: BaseEntity
{
protected TChange AggregateRootEntity { get; set; }
- private readonly IList _changes = new List();
protected void Apply(TChange item)
{
AggregateRootEntity = item;
}
- protected void Raise(IDomainEvent @event)
- {
- _changes.Add(@event);
- }
-
public TChange GetChange()
{
return AggregateRootEntity;
}
-
- public IReadOnlyList GetEvents()
- {
- return _changes.ToImmutableList();
- }
}
}
\ No newline at end of file
diff --git a/src/DFlow.Domain/DFlow.Domain.csproj b/src/DFlow.Domain/DFlow.Domain.csproj
index 26b6393..57aed38 100644
--- a/src/DFlow.Domain/DFlow.Domain.csproj
+++ b/src/DFlow.Domain/DFlow.Domain.csproj
@@ -10,10 +10,6 @@
-
-
-
-
true
diff --git a/tests/DFlow.Tests/DFlow.Tests.csproj b/tests/DFlow.Tests/DFlow.Tests.csproj
index 1484ead..4956052 100644
--- a/tests/DFlow.Tests/DFlow.Tests.csproj
+++ b/tests/DFlow.Tests/DFlow.Tests.csproj
@@ -14,6 +14,7 @@
+
diff --git a/tests/DFlow.Tests/Supporting/DomainObjects/BusinessEntityAggregateRoot.cs b/tests/DFlow.Tests/Supporting/DomainObjects/BusinessEntityAggregateRoot.cs
index 22ff00a..2b09e02 100644
--- a/tests/DFlow.Tests/Supporting/DomainObjects/BusinessEntityAggregateRoot.cs
+++ b/tests/DFlow.Tests/Supporting/DomainObjects/BusinessEntityAggregateRoot.cs
@@ -1,11 +1,12 @@
using System.Collections.Immutable;
using DFlow.Domain.Aggregates;
using DFlow.Domain.BusinessObjects;
+using DFlow.Domain.Events;
using DFlow.Tests.Supporting.DomainObjects.Events;
namespace DFlow.Tests.Supporting.DomainObjects
{
- public sealed class BusinessEntityAggregateRoot:ObjectBasedAggregationRoot
+ public sealed class BusinessEntityAggregateRoot:ObjectBasedAggregationRootWithEvents
{
internal BusinessEntityAggregateRoot(BusinessEntity businessEntity)
{
diff --git a/tests/DFlow.Tests/Supporting/DomainObjects/EventBasedAggregateFactory.cs b/tests/DFlow.Tests/Supporting/DomainObjects/EventBasedAggregateFactory.cs
index 0c6bdd7..b1e12d1 100644
--- a/tests/DFlow.Tests/Supporting/DomainObjects/EventBasedAggregateFactory.cs
+++ b/tests/DFlow.Tests/Supporting/DomainObjects/EventBasedAggregateFactory.cs
@@ -6,6 +6,7 @@
using DFlow.Domain.Aggregates;
using DFlow.Domain.BusinessObjects;
+using DFlow.Domain.Events.BusinessObjects;
using DFlow.Tests.Supporting.DomainObjects.Commands;
namespace DFlow.Tests.Supporting.DomainObjects
diff --git a/tests/DFlow.Tests/Supporting/DomainObjects/EventStreamBusinessEntityAggregateRoot.cs b/tests/DFlow.Tests/Supporting/DomainObjects/EventStreamBusinessEntityAggregateRoot.cs
index feccf92..281f763 100644
--- a/tests/DFlow.Tests/Supporting/DomainObjects/EventStreamBusinessEntityAggregateRoot.cs
+++ b/tests/DFlow.Tests/Supporting/DomainObjects/EventStreamBusinessEntityAggregateRoot.cs
@@ -1,6 +1,13 @@
+// Copyright (C) 2022 Road to Agility
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at https://mozilla.org/MPL/2.0/.
+
using System.Collections.Immutable;
-using DFlow.Domain.Aggregates;
using DFlow.Domain.BusinessObjects;
+using DFlow.Domain.Events.Aggregates;
+using DFlow.Domain.Events.BusinessObjects;
using DFlow.Tests.Supporting.DomainObjects.Events;
namespace DFlow.Tests.Supporting.DomainObjects
diff --git a/tests/DFlow.Tests/Supporting/DomainObjects/Events/EntityAddedEvent.cs b/tests/DFlow.Tests/Supporting/DomainObjects/Events/EntityAddedEvent.cs
index 7292e04..fc8f1cf 100644
--- a/tests/DFlow.Tests/Supporting/DomainObjects/Events/EntityAddedEvent.cs
+++ b/tests/DFlow.Tests/Supporting/DomainObjects/Events/EntityAddedEvent.cs
@@ -18,7 +18,7 @@
using System;
using DFlow.Domain.BusinessObjects;
-using DFlow.Domain.DomainEvents;
+using DFlow.Domain.Events.DomainEvents;
namespace DFlow.Tests.Supporting.DomainObjects.Events
{
diff --git a/tests/DFlow.Tests/Supporting/DomainObjects/Events/TestEntityAggregateAddedDomainEvent.cs b/tests/DFlow.Tests/Supporting/DomainObjects/Events/TestEntityAggregateAddedDomainEvent.cs
index 866680f..25ec394 100644
--- a/tests/DFlow.Tests/Supporting/DomainObjects/Events/TestEntityAggregateAddedDomainEvent.cs
+++ b/tests/DFlow.Tests/Supporting/DomainObjects/Events/TestEntityAggregateAddedDomainEvent.cs
@@ -18,7 +18,7 @@
using System;
using DFlow.Domain.BusinessObjects;
-using DFlow.Domain.DomainEvents;
+using DFlow.Domain.Events.DomainEvents;
namespace DFlow.Tests.Supporting.DomainObjects.Events
{
diff --git a/tests/DFlow.Tests/Supporting/DomainObjects/Events/TestEntityAggregateUpdatedDomainEvent.cs b/tests/DFlow.Tests/Supporting/DomainObjects/Events/TestEntityAggregateUpdatedDomainEvent.cs
index 765af94..246527d 100644
--- a/tests/DFlow.Tests/Supporting/DomainObjects/Events/TestEntityAggregateUpdatedDomainEvent.cs
+++ b/tests/DFlow.Tests/Supporting/DomainObjects/Events/TestEntityAggregateUpdatedDomainEvent.cs
@@ -18,7 +18,7 @@
using System;
using DFlow.Domain.BusinessObjects;
-using DFlow.Domain.DomainEvents;
+using DFlow.Domain.Events.DomainEvents;
namespace DFlow.Tests.Supporting.DomainObjects.Events
{
diff --git a/tests/DFlow.Tests/Supporting/UpdateEntityEventBasedCommandHandler.cs b/tests/DFlow.Tests/Supporting/UpdateEntityEventBasedCommandHandler.cs
index 9e71c7f..aa42c79 100644
--- a/tests/DFlow.Tests/Supporting/UpdateEntityEventBasedCommandHandler.cs
+++ b/tests/DFlow.Tests/Supporting/UpdateEntityEventBasedCommandHandler.cs
@@ -1,20 +1,9 @@
-// Copyright (C) 2020 Road to Agility
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Library General Public
-// License as published by the Free Software Foundation; either
-// version 2 of the License, or (at your option) any later version.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Library General Public License for more details.
-//
-// You should have received a copy of the GNU Library General Public
-// License along with this library; if not, write to the
-// Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
-// Boston, MA 02110-1301, USA.
+// Copyright (C) 2022 Road to Agility
//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at https://mozilla.org/MPL/2.0/.
+
using System;
using System.Collections.Immutable;
@@ -25,6 +14,7 @@
using DFlow.Domain.Aggregates;
using DFlow.Domain.BusinessObjects;
using DFlow.Domain.Events;
+using DFlow.Domain.Events.BusinessObjects;
using DFlow.Tests.Supporting.DomainObjects;
using DFlow.Tests.Supporting.DomainObjects.Commands;
@@ -32,7 +22,7 @@ namespace DFlow.Tests.Supporting
{
public sealed class UpdateEntityEventBasedCommandHandler : CommandHandler>
{
- private IAggregateFactory>
+ private readonly IAggregateFactory>
_aggregateFactory;
public UpdateEntityEventBasedCommandHandler(IDomainEventBus publisher,
@@ -47,7 +37,7 @@ protected override Task> ExecuteCommand(UpdateEntityCommand
var agg = _aggregateFactory.Create(
EventStream.From(EntityTestId.Empty(),
new AggregationName(),
- VersionId.Empty(), new ImmutableArray())
+ VersionId.Empty(), ImmutableList.Empty)
);
var isSucceed = agg.IsValid;
var okId = Guid.Empty;