@@ -14,6 +14,7 @@ public abstract class KernelCommand : IEquatable<KernelCommand>
14
14
{
15
15
private KernelCommand _parent ;
16
16
private string _token ;
17
+ private List < KernelCommand > _childCommandsToBubbleEventsFrom ;
17
18
18
19
protected KernelCommand (
19
20
string targetKernelName = null )
@@ -23,7 +24,8 @@ protected KernelCommand(
23
24
RoutingSlip = new CommandRoutingSlip ( ) ;
24
25
}
25
26
26
- [ JsonIgnore ] public KernelCommandInvocation Handler { get ; set ; }
27
+ [ JsonIgnore ]
28
+ public KernelCommandInvocation Handler { get ; set ; }
27
29
28
30
[ JsonIgnore ]
29
31
public KernelCommand Parent => _parent ;
@@ -115,17 +117,55 @@ static string CreateRootToken()
115
117
private static int _nextRootToken = 0 ;
116
118
#endif
117
119
118
- [ JsonIgnore ] internal SchedulingScope SchedulingScope { get ; set ; }
120
+ [ JsonIgnore ]
121
+ internal SchedulingScope SchedulingScope { get ; set ; }
119
122
120
- [ JsonIgnore ] internal bool ? ShouldPublishCompletionEvent { get ; set ; }
123
+ [ JsonIgnore ]
124
+ internal bool ? ShouldPublishCompletionEvent { get ; set ; }
121
125
122
126
[ JsonIgnore ]
123
127
public ParseResult KernelChooserParseResult { get ; internal set ; }
124
128
125
129
[ JsonIgnore ]
126
130
public CommandRoutingSlip RoutingSlip { get ; }
127
131
128
- internal bool ShouldResultIncludeEventsFromChildren { get ; set ; }
132
+ internal bool WasProxied { get ; set ; }
133
+
134
+ internal void ResultShouldIncludeEventsFrom ( KernelCommand childCommand )
135
+ {
136
+ if ( _childCommandsToBubbleEventsFrom is null )
137
+ {
138
+ _childCommandsToBubbleEventsFrom = new ( ) ;
139
+ }
140
+
141
+ _childCommandsToBubbleEventsFrom . Add ( childCommand ) ;
142
+ }
143
+
144
+ internal bool ShouldResultIncludeEventsFrom ( KernelCommand childCommand )
145
+ {
146
+ if ( _childCommandsToBubbleEventsFrom is null )
147
+ {
148
+ return false ;
149
+ }
150
+
151
+ for ( var i = 0 ; i < _childCommandsToBubbleEventsFrom . Count ; i ++ )
152
+ {
153
+ var command = _childCommandsToBubbleEventsFrom [ i ] ;
154
+
155
+ if ( command . Equals ( childCommand ) )
156
+ {
157
+ return true ;
158
+ }
159
+
160
+ if ( command . WasProxied &&
161
+ command . IsSelfOrDescendantOf ( this ) )
162
+ {
163
+ return true ;
164
+ }
165
+ }
166
+
167
+ return false ;
168
+ }
129
169
130
170
public virtual Task InvokeAsync ( KernelInvocationContext context )
131
171
{
0 commit comments