1
1
using Microsoft . Extensions . DependencyInjection ;
2
+ using Wolder . Core . Workspace . Events ;
2
3
3
4
namespace Wolder . Core . Workspace ;
4
5
5
6
internal class InvocationMiddleware ( IServiceProvider provider ) : IInvoke
6
7
{
7
- private readonly IWorkspaceStateDelegate _stateDelegate = provider . GetRequiredService < IWorkspaceStateDelegate > ( ) ;
8
+ private readonly WorkspaceStateEventDispatcher _stateDelegate = provider . GetRequiredService < WorkspaceStateEventDispatcher > ( ) ;
8
9
9
10
public async Task InvokeVoidAsync < TInvokable > ( )
10
11
where TInvokable : IVoidInvokable
11
12
{
12
13
using var scope = provider . CreateScope ( ) ;
13
14
var invokable = ActivatorUtilities . CreateInstance < TInvokable > ( scope . ServiceProvider ) ;
14
- await _stateDelegate . InvocationBeginAsync ( invokable , null ) ;
15
+ await _stateDelegate . Events . InvocationBeginAsync ( new ( invokable , null ) ) ;
15
16
await invokable . InvokeAsync ( ) ;
16
- await _stateDelegate . InvocationEndAsync ( ) ;
17
+ await _stateDelegate . Events . InvocationEndAsync ( new ( invokable ) ) ;
17
18
}
18
19
19
20
public async Task InvokeVoidAsync < TInvokable , TParameter > ( TParameter parameter )
@@ -22,9 +23,9 @@ public async Task InvokeVoidAsync<TInvokable, TParameter>(TParameter parameter)
22
23
{
23
24
var scope = provider . CreateScope ( ) ;
24
25
var invokable = ActivatorUtilities . CreateInstance < TInvokable > ( scope . ServiceProvider , parameter ) ;
25
- await _stateDelegate . InvocationBeginAsync ( invokable , parameter ) ;
26
+ await _stateDelegate . Events . InvocationBeginAsync ( new ( invokable , parameter ) ) ;
26
27
await invokable . InvokeAsync ( ) ;
27
- await _stateDelegate . InvocationEndAsync ( ) ;
28
+ await _stateDelegate . Events . InvocationEndAsync ( new ( invokable ) ) ;
28
29
}
29
30
30
31
public async Task < TOutput > InvokeAsync < TInvokable , TParameter , TOutput > ( TParameter parameter )
@@ -33,9 +34,9 @@ public async Task<TOutput> InvokeAsync<TInvokable, TParameter, TOutput>(TParamet
33
34
{
34
35
var scope = provider . CreateScope ( ) ;
35
36
var invokable = ActivatorUtilities . CreateInstance < TInvokable > ( scope . ServiceProvider , parameter ) ;
36
- await _stateDelegate . InvocationBeginAsync ( invokable , parameter ) ;
37
+ await _stateDelegate . Events . InvocationBeginAsync ( new ( invokable , parameter ) ) ;
37
38
var result = await invokable . InvokeAsync ( ) ;
38
- await _stateDelegate . InvocationEndAsync ( ) ;
39
+ await _stateDelegate . Events . InvocationEndAsync ( new ( invokable ) ) ;
39
40
return result ;
40
41
}
41
42
@@ -44,9 +45,9 @@ public async Task<TOutput> InvokeAsync<TInvokable, TOutput>()
44
45
{
45
46
var scope = provider . CreateScope ( ) ;
46
47
var invokable = ActivatorUtilities . CreateInstance < TInvokable > ( scope . ServiceProvider ) ;
47
- await _stateDelegate . InvocationBeginAsync ( invokable , null ) ;
48
+ await _stateDelegate . Events . InvocationBeginAsync ( new ( invokable , null ) ) ;
48
49
var result = await invokable . InvokeAsync ( ) ;
49
- await _stateDelegate . InvocationEndAsync ( ) ;
50
+ await _stateDelegate . Events . InvocationEndAsync ( new ( invokable ) ) ;
50
51
return result ;
51
52
}
52
53
}
0 commit comments