File tree Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,12 @@ public void Publish<TCommand>(TCommand command) where TCommand : Command
11
11
PublishAsync ( command ) . GetAwaiter ( ) . GetResult ( ) ;
12
12
}
13
13
14
+ public T Query < T > ( Query < T > query )
15
+ {
16
+ Publish ( query ) ;
17
+ return query . Result ;
18
+ }
19
+
14
20
public async Task PublishAsync < TCommand > ( TCommand command ) where TCommand : Command
15
21
{
16
22
if ( _subscriptions . TryGetValue ( typeof ( TCommand ) , out var handlers ) )
@@ -28,5 +34,11 @@ public async Task PublishAsync<TCommand>(TCommand command) where TCommand : Comm
28
34
}
29
35
}
30
36
}
37
+
38
+ public async Task < T > QueryAsync < T > ( Query < T > query )
39
+ {
40
+ await PublishAsync ( query ) ;
41
+ return query . Result ;
42
+ }
31
43
}
32
44
}
Original file line number Diff line number Diff line change @@ -15,6 +15,8 @@ public interface IEventBus
15
15
void Unsubscribe < TCommand > ( Action < TCommand > action ) where TCommand : Command ;
16
16
void Unsubscribe < TCommand > ( Func < TCommand , Task > asyncAction ) where TCommand : Command ;
17
17
void Publish < TCommand > ( TCommand command ) where TCommand : Command ;
18
+ T Query < T > ( Query < T > query ) ;
18
19
Task PublishAsync < TCommand > ( TCommand command ) where TCommand : Command ;
20
+ Task < T > QueryAsync < T > ( Query < T > query ) ;
19
21
}
20
22
}
Original file line number Diff line number Diff line change 3
3
<BaseIntermediateOutputPath >$(MSBuildThisFileDirectory).vs\$(SolutionName)\Intermediate\$(MSBuildProjectName)\</BaseIntermediateOutputPath >
4
4
<OutputPath >$(MSBuildThisFileDirectory)\Output\</OutputPath >
5
5
<AppendTargetFrameworkToOutputPath >True</AppendTargetFrameworkToOutputPath >
6
- <Version >3.3.1 </Version >
6
+ <Version >3.4.0 </Version >
7
7
</PropertyGroup >
8
8
</Project >
You can’t perform that action at this time.
0 commit comments