Skip to content

Commit 08e6a15

Browse files
committed
- Checkpoint: Refactor Code
1 parent 4c98528 commit 08e6a15

File tree

12 files changed

+85
-54
lines changed

12 files changed

+85
-54
lines changed

src/SourceFlow.ConsoleApp/Impl/InMemoryViewRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace SourceFlow.ConsoleApp.Impl
44
{
5-
public class InMemoryViewRepository : IViewModelRepository
5+
public class InMemoryViewRepository : IViewRepository
66
{
77
private readonly ConcurrentDictionary<int, IViewModel> _cache = new();
88

src/SourceFlow.ConsoleApp/Services/AccountViewFinder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace SourceFlow.ConsoleApp.Services
44
{
55
public class AccountViewFinder : BaseViewFinder, IAccountFinder
66
{
7-
public AccountViewFinder(IViewModelRepository repository) : base(repository)
7+
public AccountViewFinder(IViewRepository repository) : base(repository)
88
{
99
}
1010

src/SourceFlow.ConsoleApp/ViewModels/AccountViewTransforms.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ public class AccountViewTransforms : IViewTransform<AccountCreated>
77
, IViewTransform<MoneyWithdrawn>
88
, IViewTransform<AccountClosed>
99
{
10-
private readonly IViewModelRepository repository;
10+
private readonly IViewRepository repository;
1111

12-
public AccountViewTransforms(IViewModelRepository repository)
12+
public AccountViewTransforms(IViewRepository repository)
1313
{
1414
this.repository = repository ?? throw new ArgumentNullException(nameof(repository));
1515
}

src/SourceFlow/BaseViewFinder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ public abstract class BaseViewFinder : IViewFinder
1111
/// <summary>
1212
/// Repository for managing view models.
1313
/// </summary>
14-
protected readonly IViewModelRepository repository;
14+
protected readonly IViewRepository repository;
1515

1616
/// <summary>
1717
/// Initializes a new instance of the <see cref="BaseViewFinder"/> class.
1818
/// </summary>
1919
/// <param name="repository"></param>
2020
/// <exception cref="ArgumentNullException"></exception>
21-
protected BaseViewFinder(IViewModelRepository repository)
21+
protected BaseViewFinder(IViewRepository repository)
2222
{
2323
this.repository = repository ?? throw new ArgumentNullException(nameof(repository));
2424
}

src/SourceFlow/BaseViewTransform.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public abstract class BaseViewTransform<TEvent> : IViewTransform<TEvent>
1212
/// <summary>
1313
/// Repository for managing view models.
1414
/// </summary>
15-
protected IViewModelRepository ViewModelRepository { get; set; }
15+
protected IViewRepository ViewRepository { get; set; }
1616

1717
/// <summary>
1818
/// Transform the event to view model.

src/SourceFlow/ClassDiagram.cd

Lines changed: 69 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<ClassDiagram MajorVersion="1" MinorVersion="1">
33
<Class Name="SourceFlow.BaseAggregate&lt;TAggregateEntity&gt;">
4-
<Position X="4" Y="3.25" Width="2" />
4+
<Position X="7.25" Y="1.5" Width="2" />
5+
<AssociationLine Name="eventReplayer" Type="SourceFlow.IEventReplayer" ManuallyRouted="true" FixedFromPoint="true" FixedToPoint="true">
6+
<Path>
7+
<Point X="7.25" Y="3.062" />
8+
<Point X="6.508" Y="3.062" />
9+
<Point X="6.508" Y="3.065" />
10+
<Point X="5" Y="3.065" />
11+
<Point X="5" Y="3.75" />
12+
</Path>
13+
<MemberNameLabel ManuallyPlaced="true">
14+
<Position X="-2.1" Y="0.818" />
15+
</MemberNameLabel>
16+
</AssociationLine>
517
<TypeIdentifier>
618
<HashCode>AgQAAAAAAAABAAACAAAAAAAAAAAAAAAAAAAAAAAAAEA=</HashCode>
719
<FileName>BaseAggregate.cs</FileName>
@@ -13,15 +25,16 @@
1325
<Lollipop Position="0.2" />
1426
</Class>
1527
<Class Name="SourceFlow.BaseSaga&lt;TAggregateEntity&gt;">
16-
<Position X="12.5" Y="3.5" Width="2.25" />
28+
<Position X="12.5" Y="4" Width="2.25" />
1729
<AssociationLine Name="busPublisher" Type="SourceFlow.IBusPublisher" ManuallyRouted="true" FixedFromPoint="true" FixedToPoint="true">
1830
<Path>
19-
<Point X="12.5" Y="4.932" />
20-
<Point X="9.72" Y="4.932" />
21-
<Point X="9.72" Y="2.875" />
22-
<Point X="1.5" Y="2.875" />
23-
<Point X="1.5" Y="3.25" />
31+
<Point X="12.5" Y="5.75" />
32+
<Point X="10.812" Y="5.75" />
33+
<Point X="10.812" Y="4.853" />
2434
</Path>
35+
<MemberNameLabel ManuallyPlaced="true">
36+
<Position X="-1.55" Y="0.629" />
37+
</MemberNameLabel>
2538
</AssociationLine>
2639
<TypeIdentifier>
2740
<HashCode>AAQAAAAAAAAHAAACBQAAAAACAAAAAAAAAAAAAAAAAAA=</HashCode>
@@ -34,7 +47,12 @@
3447
<Lollipop Position="0.7" />
3548
</Class>
3649
<Class Name="SourceFlow.BaseEvent&lt;TPayload&gt;">
37-
<Position X="10" Y="2.5" Width="1.75" />
50+
<Position X="16" Y="0.75" Width="1.75" />
51+
<AssociationLine Name="Entity" Type="SourceFlow.Source">
52+
<MemberNameLabel ManuallyPlaced="true">
53+
<Position X="0.998" Y="0.103" />
54+
</MemberNameLabel>
55+
</AssociationLine>
3856
<TypeIdentifier>
3957
<HashCode>EAAAAAAgAgAAAAAAAAAQAQAAAAAAAAAQAAAAAAAAAAA=</HashCode>
4058
<FileName>BaseEvent.cs</FileName>
@@ -45,28 +63,27 @@
4563
<Lollipop Position="0.2" />
4664
</Class>
4765
<Class Name="SourceFlow.BaseViewTransform&lt;TEvent&gt;">
48-
<Position X="3.75" Y="11.25" Width="2.5" />
49-
<AssociationLine Name="ViewModelRepository" Type="SourceFlow.IViewModelRepository" ManuallyRouted="true" FixedFromPoint="true" FixedToPoint="true">
66+
<Position X="4" Y="12.75" Width="2.25" />
67+
<AssociationLine Name="ViewRepository" Type="SourceFlow.IViewRepository" ManuallyRouted="true" FixedFromPoint="true">
5068
<Path>
51-
<Point X="5" Y="12.353" />
52-
<Point X="5" Y="13.438" />
53-
<Point X="7" Y="13.438" />
69+
<Point X="6.25" Y="13.188" />
70+
<Point X="8" Y="13.188" />
5471
</Path>
5572
<MemberNameLabel ManuallyPlaced="true">
56-
<Position X="0.6" Y="0.097" />
73+
<Position X="0.305" Y="0.093" />
5774
</MemberNameLabel>
5875
</AssociationLine>
5976
<TypeIdentifier>
60-
<HashCode>AAAAAAIAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAA=</HashCode>
77+
<HashCode>AAAAAAAAAAAAAAAAAAAAAAQAAAAgAAAAAAAAAAAAAAA=</HashCode>
6178
<FileName>BaseViewTransform.cs</FileName>
6279
</TypeIdentifier>
6380
<ShowAsAssociation>
64-
<Property Name="ViewModelRepository" />
81+
<Property Name="ViewRepository" />
6582
</ShowAsAssociation>
6683
<Lollipop Position="0.2" />
6784
</Class>
6885
<Class Name="SourceFlow.BaseViewFinder">
69-
<Position X="7" Y="11.25" Width="2.25" />
86+
<Position X="8" Y="11" Width="2.25" />
7087
<TypeIdentifier>
7188
<HashCode>AAAAAAAAAAACAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAA=</HashCode>
7289
<FileName>BaseViewFinder.cs</FileName>
@@ -77,7 +94,7 @@
7794
<Lollipop Position="0.2" />
7895
</Class>
7996
<Class Name="SourceFlow.Impl.BusSubscriber">
80-
<Position X="9.75" Y="5.75" Width="2" />
97+
<Position X="9.75" Y="6.25" Width="2" />
8198
<TypeIdentifier>
8299
<HashCode>AAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAIAA=</HashCode>
83100
<FileName>Impl\BusSubscriber.cs</FileName>
@@ -88,7 +105,7 @@
88105
<Lollipop Position="0.2" />
89106
</Class>
90107
<Class Name="SourceFlow.Impl.EventReplayer">
91-
<Position X="7.25" Y="5" Width="2" />
108+
<Position X="0.75" Y="3.75" Width="2" />
92109
<TypeIdentifier>
93110
<HashCode>AAAAAAAAAAAIAAAAAAAAAAACAAAAAAAAAAAAAAAAAAA=</HashCode>
94111
<FileName>Impl\EventReplayer.cs</FileName>
@@ -125,7 +142,7 @@
125142
<Lollipop Position="0.2" />
126143
</Class>
127144
<Class Name="SourceFlow.Impl.BusPublisher">
128-
<Position X="0.5" Y="5" Width="2" />
145+
<Position X="7.25" Y="4.75" Width="2" />
129146
<TypeIdentifier>
130147
<HashCode>AAAAAAAAAAAAAAAAAAAAEAACAAAAAAAAAAAAAAAAAAA=</HashCode>
131148
<FileName>Impl\BusPublisher.cs</FileName>
@@ -136,43 +153,43 @@
136153
<Lollipop Position="0.2" />
137154
</Class>
138155
<Class Name="SourceFlow.Impl.AggregateFactory">
139-
<Position X="3.75" Y="0.5" Width="2.25" />
156+
<Position X="0.75" Y="1.5" Width="2" />
140157
<TypeIdentifier>
141158
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAABAEAAAAAAAAAAAAA=</HashCode>
142159
<FileName>Impl\AggregateFactory.cs</FileName>
143160
</TypeIdentifier>
144161
<Lollipop Position="0.2" />
145162
</Class>
146163
<Class Name="SourceFlow.Source" Collapsed="true">
147-
<Position X="12.75" Y="2.25" Width="1.5" />
164+
<Position X="12.75" Y="2.75" Width="1.5" />
148165
<TypeIdentifier>
149166
<HashCode>AAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAA=</HashCode>
150167
<FileName>Source.cs</FileName>
151168
</TypeIdentifier>
152169
</Class>
153170
<Interface Name="SourceFlow.IEventStore">
154-
<Position X="9.75" Y="8.25" Width="2.25" />
171+
<Position X="8" Y="8.5" Width="2.25" />
155172
<TypeIdentifier>
156173
<HashCode>ABAAgAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAA=</HashCode>
157174
<FileName>IEventStore.cs</FileName>
158175
</TypeIdentifier>
159176
</Interface>
160177
<Interface Name="SourceFlow.IBusPublisher">
161-
<Position X="0.5" Y="3.25" Width="2" />
178+
<Position X="9.75" Y="3.75" Width="2" />
162179
<TypeIdentifier>
163180
<HashCode>AAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
164181
<FileName>IBusPublisher.cs</FileName>
165182
</TypeIdentifier>
166183
</Interface>
167184
<Interface Name="SourceFlow.IEventReplayer">
168-
<Position X="7.25" Y="3.25" Width="2" />
185+
<Position X="4" Y="3.75" Width="2" />
169186
<TypeIdentifier>
170187
<HashCode>AgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
171188
<FileName>IEventReplayer.cs</FileName>
172189
</TypeIdentifier>
173190
</Interface>
174191
<Interface Name="SourceFlow.IDomainRepository">
175-
<Position X="16" Y="3.25" Width="2" />
192+
<Position X="16" Y="3.75" Width="2" />
176193
<TypeIdentifier>
177194
<HashCode>AAAAAAAAAAAAAABAAAAAAAIAAAEAAAAAAAAAAAAAAAA=</HashCode>
178195
<FileName>IDomainRepository.cs</FileName>
@@ -186,7 +203,7 @@
186203
</TypeIdentifier>
187204
</Interface>
188205
<Interface Name="SourceFlow.IAggregateFactory">
189-
<Position X="0.5" Y="0.5" Width="2.25" />
206+
<Position X="4" Y="1.5" Width="2" />
190207
<TypeIdentifier>
191208
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAA=</HashCode>
192209
<FileName>IAggregateFactory.cs</FileName>
@@ -199,50 +216,64 @@
199216
<FileName>IViewPublisher.cs</FileName>
200217
</TypeIdentifier>
201218
</Interface>
202-
<Interface Name="SourceFlow.IViewModelRepository">
203-
<Position X="7" Y="13" Width="2.25" />
219+
<Interface Name="SourceFlow.IViewRepository">
220+
<Position X="8" Y="12.75" Width="2.25" />
204221
<TypeIdentifier>
205222
<HashCode>AAAAAAAAAAAAAABAAAAAAAIAAAEAAAAAAAAAAAAAAAA=</HashCode>
206223
<FileName>IViewRepository.cs</FileName>
207224
</TypeIdentifier>
208225
</Interface>
209226
<Interface Name="SourceFlow.ISaga">
210-
<Position X="12.5" Y="7" Width="2.25" />
227+
<Position X="12.5" Y="7.25" Width="2.25" />
211228
<TypeIdentifier>
212229
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAA=</HashCode>
213230
<FileName>ISaga.cs</FileName>
214231
</TypeIdentifier>
215232
</Interface>
216233
<Interface Name="SourceFlow.ISagaHandler&lt;TEvent&gt;">
217-
<Position X="12.5" Y="8.5" Width="2.25" />
234+
<Position X="12.5" Y="8.75" Width="2.25" />
218235
<TypeIdentifier>
219236
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAA=</HashCode>
220237
<FileName>ISagaHandler.cs</FileName>
221238
</TypeIdentifier>
222239
</Interface>
223240
<Interface Name="SourceFlow.IViewTransform&lt;TEvent&gt;">
224-
<Position X="0.5" Y="13" Width="2" />
241+
<Position X="4" Y="11" Width="2.25" />
225242
<TypeIdentifier>
226243
<HashCode>AAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAA=</HashCode>
227244
<FileName>IViewTransform.cs</FileName>
228245
</TypeIdentifier>
229246
</Interface>
230247
<Interface Name="SourceFlow.IViewModel">
231-
<Position X="9.75" Y="10.25" Width="2.25" />
248+
<Position X="10.75" Y="12.75" Width="2.25" />
232249
<TypeIdentifier>
233250
<HashCode>AAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
234251
<FileName>IViewModel.cs</FileName>
235252
</TypeIdentifier>
236253
</Interface>
237254
<Interface Name="SourceFlow.IEvent&lt;TPayload&gt;">
238-
<Position X="10" Y="0.5" Width="1.75" />
255+
<Position X="12.5" Y="0.75" Width="1.75" />
256+
<InheritanceLine Type="SourceFlow.IEvent" ManuallyRouted="true" FixedFromPoint="true" FixedToPoint="true">
257+
<Path>
258+
<Point X="10.688" Y="1.5" />
259+
<Point X="10.688" Y="0.937" />
260+
<Point X="12.525" Y="0.937" />
261+
<Point X="12.525" Y="0.938" />
262+
<Point X="12.5" Y="0.938" />
263+
</Path>
264+
</InheritanceLine>
239265
<TypeIdentifier>
240266
<HashCode>AAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
241267
<FileName>IEvent.cs</FileName>
242268
</TypeIdentifier>
243269
</Interface>
244270
<Interface Name="SourceFlow.IEvent">
245-
<Position X="7.25" Y="0.5" Width="2" />
271+
<Position X="9.75" Y="1.5" Width="2" />
272+
<AssociationLine Name="Entity" Type="SourceFlow.Source">
273+
<MemberNameLabel ManuallyPlaced="true">
274+
<Position X="0.317" Y="0.117" />
275+
</MemberNameLabel>
276+
</AssociationLine>
246277
<TypeIdentifier>
247278
<HashCode>EAAAAAAgAgAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAA=</HashCode>
248279
<FileName>IEvent.cs</FileName>
@@ -252,14 +283,14 @@
252283
</ShowAsAssociation>
253284
</Interface>
254285
<Interface Name="SourceFlow.IEntity">
255-
<Position X="16" Y="5" Width="2" />
286+
<Position X="16" Y="5.5" Width="2" />
256287
<TypeIdentifier>
257288
<HashCode>AAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
258289
<FileName>IEntity.cs</FileName>
259290
</TypeIdentifier>
260291
</Interface>
261292
<Interface Name="SourceFlow.IViewFinder">
262-
<Position X="7" Y="9.5" Width="2.25" />
293+
<Position X="10.75" Y="11" Width="2.25" />
263294
<TypeIdentifier>
264295
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAA=</HashCode>
265296
<FileName>IViewFinder.cs</FileName>
@@ -273,7 +304,7 @@
273304
</TypeIdentifier>
274305
</Interface>
275306
<Interface Name="SourceFlow.IEventPayload">
276-
<Position X="12.25" Y="0.5" Width="1.5" />
307+
<Position X="18.25" Y="0.75" Width="1.5" />
277308
<TypeIdentifier>
278309
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
279310
<FileName>IEventPayload.cs</FileName>

src/SourceFlow/IViewRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace SourceFlow
44
{
5-
public interface IViewModelRepository
5+
public interface IViewRepository
66
{
77
/// <summary>
88
/// Retrieves an view model by unique identifier.

src/SourceFlow/IocExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public static void UseSourceFlow(this IServiceCollection services)
3838
public static void UseSourceFlow(this IServiceCollection services, Action<ISourceFlowConfig> configuration)
3939
{
4040
services.AddAsImplementationsOfInterface<IDomainRepository>(lifetime: ServiceLifetime.Singleton);
41-
services.AddAsImplementationsOfInterface<IViewModelRepository>(lifetime: ServiceLifetime.Singleton);
41+
services.AddAsImplementationsOfInterface<IViewRepository>(lifetime: ServiceLifetime.Singleton);
4242
services.AddAsImplementationsOfInterface<IEventStore>(lifetime: ServiceLifetime.Singleton);
4343
services.AddAsImplementationsOfInterface<IViewFinder>(lifetime: ServiceLifetime.Singleton);
4444
services.AddAsImplementationsOfInterface<IViewTransform>(lifetime: ServiceLifetime.Singleton);

tests/SourceFlow.Core.Tests/E2E/E2E.Tests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class ProgramIntegrationTests
1212
private IAccountService _accountService;
1313
private ISaga _saga;
1414
private ILogger _logger;
15-
private IViewModelRepository _viewRepository;
15+
private IViewRepository _viewRepository;
1616

1717
[SetUp]
1818
public void SetUp()
@@ -34,7 +34,7 @@ public void SetUp()
3434
_accountService = _serviceProvider.GetRequiredService<IAccountService>();
3535
_saga = _serviceProvider.GetRequiredService<ISaga>();
3636
_logger = _serviceProvider.GetRequiredService<ILogger<ProgramIntegrationTests>>();
37-
_viewRepository = _serviceProvider.GetRequiredService<IViewModelRepository>();
37+
_viewRepository = _serviceProvider.GetRequiredService<IViewRepository>();
3838
}
3939

4040
[TearDown]

tests/SourceFlow.Core.Tests/E2E/Impl/InMemoryViewRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace SourceFlow.Core.Tests.E2E.Impl
44
{
5-
public class InMemoryViewRepository : IViewModelRepository
5+
public class InMemoryViewRepository : IViewRepository
66
{
77
private readonly ConcurrentDictionary<int, IViewModel> _cache = new();
88

0 commit comments

Comments
 (0)