File tree 2 files changed +17
-2
lines changed
src/Api/PubnubApi/EventEngine/Core
2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ public class EffectDispatcher {
13
13
/// <summary>
14
14
/// Dispatch an invocation i.e. call a registered effect handler.
15
15
/// </summary>
16
- public async Task Dispatch < T > ( T invocation ) where T : IEffectInvocation {
16
+ public async Task Dispatch ( IEffectInvocation invocation ) {
17
17
if ( ! effectInvocationHandlerMap . ContainsKey ( invocation . GetType ( ) ) ) {
18
18
throw new ArgumentException ( $ "No handler for { invocation . GetType ( ) . Name } found.") ;
19
19
}
@@ -24,7 +24,7 @@ public async Task Dispatch<T>(T invocation) where T : IEffectInvocation {
24
24
await effectInvocationHandlerMap [ invocation . GetType ( ) ] . Cancel ( ) ;
25
25
} else
26
26
{
27
- var handler = ( ( IEffectHandler < T > ) effectInvocationHandlerMap [ invocation . GetType ( ) ] ) ;
27
+ var handler = effectInvocationHandlerMap [ invocation . GetType ( ) ] ;
28
28
if ( handler . IsBackground ( invocation ) )
29
29
handler . Run ( invocation ) . Start ( ) ;
30
30
else
Original file line number Diff line number Diff line change 1
1
using System ;
2
2
using System . Threading . Tasks ;
3
3
using System . Collections . Generic ;
4
+ using System . Reflection ;
4
5
5
6
namespace PubnubApi . EventEngine . Core
6
7
{
@@ -17,6 +18,20 @@ internal static IEffectInvocation[] AsArray(this IEffectInvocation invocation)
17
18
{
18
19
return new IEffectInvocation [ ] { invocation } ;
19
20
}
21
+
22
+ internal static bool IsBackground ( this IEffectHandler handler , IEffectInvocation invocation )
23
+ {
24
+ return ( bool ) handler . GetType ( )
25
+ . GetMethod ( "IsBackground" )
26
+ . Invoke ( handler , new object [ ] { invocation } ) ;
27
+ }
28
+
29
+ internal static Task Run ( this IEffectHandler handler , IEffectInvocation invocation )
30
+ {
31
+ return ( Task ) handler . GetType ( )
32
+ . GetMethod ( "Run" )
33
+ . Invoke ( handler , new object [ ] { invocation } ) ;
34
+ }
20
35
}
21
36
22
37
public class TransitionResult
You can’t perform that action at this time.
0 commit comments