public bool CanExecute(PatternState state) { TraceItem trace = state.Trace.OnCanExecute(this); bool result = OnCanExecute(state); trace.Update(result); return(result); }
private TraceItem StartTrace(TraceKind kind, PatternElement source) { TraceItem traceElement = new TraceItem { Kind = kind, PatternElement = source, State = TraceState.InProgress }; Items.Add(traceElement); if (!Tally.TryGetValue(source, out TallyEntry entry)) { entry = new TallyEntry { LastPosition = 0, Count = 0 }; Tally.Add(source, entry); } if (entry.LastPosition != State.Enumerator.Index) { entry.Count = 0; entry.LastPosition = State.Enumerator.Index; } entry.Count++; if (entry.Count > CycleThreshold) { throw new Exception("Possible cycle detected!"); } return(traceElement); }