protected void OnEventInvoked(FunctionScopeArg arg) { if (EventInvoked != null) { EventInvoked.Invoke(arg); } else { arg.OnEndInvoked(); } }
private void InvokeEventImpl(string eventName, object arg, Action <bool> allEnd) { var scopeArg = new FunctionScopeArg(eventName, arg, (e) => { if (!e.Handled) { bool anyHandled = false; int currentEndCount = 0; Action childInvokeEnd = () => { if (!anyHandled) { var scopeArg2 = new FunctionScopeArg(eventName, arg, (e2) => { if (allEnd != null) { allEnd.Invoke(anyHandled | e2.Handled); } }); OnEventInvoked(scopeArg2); } }; if (childScopes.Count > 0) { foreach (FunctionScope child in childScopes) { child.InvokeEventImpl(eventName, arg, (handled) => { anyHandled |= handled; currentEndCount++; if (currentEndCount == childScopes.Count) { childInvokeEnd.Invoke(); } }); } } else { childInvokeEnd.Invoke(); } } }); OnPreviewEventInvoked(scopeArg); }