/// <summary> /// Raise the event. /// </summary> /// <param name="expression">The <see cref="Expression"/> used.</param> public void OnExecuteEnumerableCalled(Expression expression) { if (Parent != null) { Parent.OnExecuteEnumerableCalled(expression); return; } QueryExecuted?.Invoke(this, new QuerySnapshotEventArgs(expression)); }
public void Back() { if (_historyHead <= 0) { return; } --_historyHead; QueryExecuted?.Invoke(this, new QueryEventArgs(Current)); }
public void Forward() { if (_historyHead >= _history.Count - 1) { return; } ++_historyHead; QueryExecuted?.Invoke(this, new QueryEventArgs(Current)); }
public bool ExecuteQuery(IExecutableQuery query) { if (query == null) { throw new ArgumentNullException(nameof(query)); } // trigger the BeforeQueryExecuted event and potentially cancel the operation var args = new BeforeQueryExecutedEventArgs(query); BeforeQueryExecuted?.Invoke(this, args); if (args.IsCanceled) { return(false); } // only modify the history if the queries differ if (Current == null || StringComparer.CurrentCultureIgnoreCase.Compare(query.Text, Current.Text) != 0) { // remove all entries in history after _historyHead var index = _history.Count - 1; while (index > _historyHead) { _history.RemoveAt(index--); } // add a new query to history and make it the current query _history.Add(query); ++_historyHead; Trace.Assert(_historyHead == _history.Count - 1); } // trigger query executed event QueryExecuted?.Invoke(this, new QueryEventArgs(query)); return(true); }