public QueryResults(QueryResults copy) { Parameters = copy.Parameters; SourceRows = copy.SourceRows; PivotedRows = copy.PivotedRows; ItemProperties = copy.ItemProperties; FilteredRows = copy.FilteredRows; SortedRows = copy.SortedRows; }
public QueryResults SetParameters(QueryParameters newParameters) { var result = new QueryResults { Parameters = newParameters }; if (Parameters.PivotValid(result.Parameters)) { result.PivotedRows = PivotedRows; result.ItemProperties = ItemProperties; if (Parameters.FilterValid(newParameters)) { result.FilteredRows = FilteredRows; if (Parameters.SortValid(newParameters)) { result.SortedRows = SortedRows; } else { result.SortedRows = null; } } else { result.FilteredRows = result.SortedRows = null; } } else { if (result.Parameters.ViewInfo == null) { result.SortedRows = result.FilteredRows = result.PivotedRows = Empty.ResultRows; } else { result.SortedRows = result.FilteredRows = result.PivotedRows = null; } result.ItemProperties = null; } return result; }
public void SetFinalQueryResults(QueryResults newResults) { var action = new Action(() => { try { LiveQueryResults = _queryRequestor._rowSourceWrapper.MakeLive(newResults); _queryRequestor._bindingListView.UpdateResults(); } catch (Exception exception) { OnUnhandledException(exception); } }); if (null == EventTaskScheduler) { action.Invoke(); } else { Task.Factory.StartNew(action, _cancellationTokenSource.Token, TaskCreationOptions.None, EventTaskScheduler); } }
protected PivotedRows Pivot(CancellationToken cancellationToken, QueryResults results) { var pivoter = new Pivoter(results.Parameters.ViewInfo); return(pivoter.ExpandAndPivot(cancellationToken, results.SourceRows)); }
public abstract QueryResults MakeLive(QueryResults rowItems);
protected IEnumerable <RowItem> Filter(CancellationToken cancellationToken, QueryResults results) { var unfilteredRows = results.PivotedRows; var filter = results.Parameters.RowFilter; if (filter.IsEmpty) { return(unfilteredRows); } var properties = results.ItemProperties; Predicate <object>[] columnPredicates = new Predicate <object> [properties.Count]; for (int i = 0; i < properties.Count; i++) { columnPredicates[i] = filter.GetPredicate(results.Parameters.ViewInfo.DataSchema, properties[i]); } var filteredRows = new List <RowItem>(); // toString on an enum is incredibly slow, so we cache the results in // in a dictionary. var toStringCaches = new Dictionary <object, string> [properties.Count]; for (int i = 0; i < properties.Count; i++) { var property = properties[i]; if (property.PropertyType.IsEnum) { toStringCaches[i] = new Dictionary <object, string>(); } } foreach (var row in unfilteredRows) { bool matchesText = string.IsNullOrEmpty(filter.Text); bool matchesFilter = true; for (int iProperty = 0; iProperty < properties.Count; iProperty++) { cancellationToken.ThrowIfCancellationRequested(); var predicate = columnPredicates[iProperty]; if (matchesText && null == predicate) { continue; } var property = properties[iProperty]; var value = property.GetValue(row); if (!matchesText && value != null) { var cache = toStringCaches[iProperty]; string strValue; if (cache == null) { strValue = value.ToString(); } else { if (!cache.TryGetValue(value, out strValue)) { strValue = value.ToString(); cache.Add(value, strValue); } } if (filter.MatchesText(strValue)) { matchesText = true; } } matchesFilter = null == predicate || predicate(value); if (!matchesFilter) { break; } } if (matchesText && matchesFilter) { filteredRows.Add(row); } } if (filteredRows.Count == unfilteredRows.Count) { return(unfilteredRows); } return(filteredRows); }
protected QueryResults Pivot(Pivoter.TickCounter tickCounter, QueryResults results) { var pivoter = new Pivoter(results.Parameters.ViewInfo); return(results.SetPivotedRows(pivoter.ExpandAndPivot(tickCounter, results.SourceRows))); }
public abstract QueryResults MakeLive(QueryResults rowItems);
public override QueryResults MakeLive(QueryResults rowItems) { return(rowItems); }
public void Dispose() { RowSource = null; _queryRequestor.Dispose(); _queryResults = null; }
public override QueryResults MakeLive(QueryResults rowItems) { return rowItems; }