File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
src/Api/PubnubApi/EventEngine/Core Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ public class EffectDispatcher {
1313 /// <summary>
1414 /// Dispatch an invocation i.e. call a registered effect handler.
1515 /// </summary>
16- public async Task Dispatch < T > ( T invocation ) where T : IEffectInvocation {
16+ public async Task Dispatch ( IEffectInvocation invocation ) {
1717 if ( ! effectInvocationHandlerMap . ContainsKey ( invocation . GetType ( ) ) ) {
1818 throw new ArgumentException ( $ "No handler for { invocation . GetType ( ) . Name } found.") ;
1919 }
@@ -24,7 +24,7 @@ public async Task Dispatch<T>(T invocation) where T : IEffectInvocation {
2424 await effectInvocationHandlerMap [ invocation . GetType ( ) ] . Cancel ( ) ;
2525 } else
2626 {
27- var handler = ( ( IEffectHandler < T > ) effectInvocationHandlerMap [ invocation . GetType ( ) ] ) ;
27+ var handler = effectInvocationHandlerMap [ invocation . GetType ( ) ] ;
2828 if ( handler . IsBackground ( invocation ) )
2929 handler . Run ( invocation ) . Start ( ) ;
3030 else
Original file line number Diff line number Diff line change 11using System ;
22using System . Threading . Tasks ;
33using System . Collections . Generic ;
4+ using System . Reflection ;
45
56namespace PubnubApi . EventEngine . Core
67{
@@ -17,6 +18,20 @@ internal static IEffectInvocation[] AsArray(this IEffectInvocation invocation)
1718 {
1819 return new IEffectInvocation [ ] { invocation } ;
1920 }
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+ }
2035 }
2136
2237 public class TransitionResult
You can’t perform that action at this time.
0 commit comments