public static void TriggerEventHandler <TArgs>(this GraphStack stack, Func <EventHook, bool> predicate, TArgs args, Func <IGraphParentElement, bool> recurse, bool force) { Ensure.That(nameof(stack)).IsNotNull(stack); GraphReference reference = null; foreach (var element in stack.graph.elements) { if (element is IGraphEventHandler <TArgs> handler) { if (reference == null) { reference = stack.ToReference(); } if (predicate == null || predicate.Invoke(handler.GetHook(reference))) { if (force || handler.IsListening(reference)) { handler.Trigger(reference, args); } } } if (element is IGraphParentElement parentElement && recurse(parentElement)) { if (stack.TryEnterParentElementUnsafe(parentElement)) { stack.TriggerEventHandler(predicate, args, recurse, force); stack.ExitParentElement(); } } } }
public void StopListening(GraphStack stack) { if (stack.TryEnterParentElement(this)) { nest.graph.StopListening(stack); stack.ExitParentElement(); } }
public void StopListening(GraphStack stack) { stack.GetElementData <Data>(this).isListening = false; if (stack.TryEnterParentElement(this)) { nest.graph.StopListening(stack); stack.ExitParentElement(); } }
public void StartListening(GraphStack stack) { if (stack.TryEnterParentElement(this)) { nest.graph.StartListening(stack); stack.ExitParentElement(); } stack.GetElementData <Data>(this).isListening = true; }