public T GetValue <T>(string columnId, int rowIndex) { int realRowIndex; if (_filterRowToSourceRow.TryGetValue(rowIndex, out realRowIndex)) { return(_sourceTable.GetValue <T>(columnId, realRowIndex)); } return(default(T)); }
public T GetValue <T>(string columnId, int rowIndex) { IReactiveColumn column; // Use the joiner for when the column is defined directly on them // if the table is a joined table delegate the joining to it. if (_leftTable.GetColumnByName(columnId, out column)) { return(_leftTable.GetValue <T>(columnId, _joiner.GetRowIndex(column, rowIndex))); } if (_rightTable.GetColumnByName(columnId, out column)) { return(_rightTable.GetValue <T>(columnId, _joiner.GetRowIndex(column, rowIndex))); } // Otherwise return calc'ed columns return(GetColumn <T>(columnId).GetValue(rowIndex)); }
/// <summary> /// 1. New row arrives /// - Need to propagate event at the righ row position /// - Update the positions of other rows (invalidate the view) /// 2. Row is updated /// - If the key column changes we need to re-sort and then do a BinarySearch to find the new position /// - If another column changes we need to find the row position using the key and BinarySearch to propagate /// - Update the positions of other rows (invalidate the view) /// 3. Row at position X scrolls into view /// - Go get the row id at the given position /// </summary> /// <param name="update"></param> /// <param name="needToResort"></param> /// <returns></returns> public int OnNext(TableUpdate update, out bool needToResort) { var sortColValue = _sourceTable.GetValue <T>(_sortColumnId, update.RowIndex); var keyValuePair = new KeyValuePair <T, int>(sortColValue, update.RowIndex); needToResort = false; var sortedRowId = -1; switch (update.Action) { case TableUpdateAction.Add: _keysToRows.Add(keyValuePair); _rowIdsToValues.Add(update.RowIndex, sortColValue); needToResort = true; break; case TableUpdateAction.Delete: sortedRowId = _keysToRows.BinarySearch(keyValuePair, _keyComparer); _keysToRows.RemoveAt(sortedRowId); _rowIdsToValues.Remove(update.RowIndex); needToResort = true; break; case TableUpdateAction.Update: { // Sort column updating if (update.Column.ColumnId == _sortColumnId) { var oldValue = _rowIdsToValues[update.RowIndex]; var oldSortColValue = new KeyValuePair <T, int>(oldValue, update.RowIndex); _keysToRows[_keysToRows.BinarySearch(oldSortColValue, _keyComparer)] = keyValuePair; _rowIdsToValues[update.RowIndex] = sortColValue; needToResort = true; } // Other column - row can't change position else { // In order to avoid this binary search and others should we rather keep build a list of rowIds to indeces at each re-sort? sortedRowId = _keysToRows.BinarySearch(keyValuePair, _keyComparer); } } break; } // Keep the table sorted if (needToResort) { _keysToRows.Sort((pair1, pair2) => _comparer.Compare(pair1.Key, pair2.Key)); sortedRowId = _keysToRows.BinarySearch(keyValuePair, _keyComparer); } // Find the now row id else if (sortedRowId < 0) { sortedRowId = _keysToRows.BinarySearch(keyValuePair, _keyComparer); } return(sortedRowId); }
public static void SetAndTestValueNotPresent <T>(IWritableReactiveTable setTable, IReactiveTable getTable, int setRowId, int getRowId, T value, string columnId) { setTable.SetValue(columnId, setRowId, value); Assert.AreEqual(default(T), getTable.GetValue <T>(columnId, getRowId)); }
public virtual T GetValue <T>(int rowIndex, int columnIndex) { IReactiveColumn column; var row = GetColAndRowFromGridCoordinates <T>(rowIndex, columnIndex, out column); if (column != null && row >= 0) { return(_table.GetValue <T>(column.ColumnId, row)); } return(default(T)); }
public static void TestValue <T>(IReactiveTable table, int rowId, T value, string columnId) { Assert.AreEqual(value, table.GetValue <T>(columnId, rowId)); }
public bool RowIsVisible(IReactiveTable sourceTable, int rowIndex) { return(_predicate(sourceTable.GetValue <T1>(_column1, rowIndex), sourceTable.GetValue <T2>(_column2, rowIndex))); }
protected TColumn GetValue <TColumn>([CallerMemberName] string propertyName = "") { return(_table.GetValue <TColumn>(_columnIdByPopertyNames[propertyName], _index)); }
public T GetValue <T>(string columnId, int rowIndex) { var sourceRowId = _sorter.GetRowAt(rowIndex); return(_sourceTable.GetValue <T>(columnId, sourceRowId)); }
private void WriteColumn(ProtoWriter writer, IReactiveColumn column, int fieldId, int rowId) { if (column.Type == typeof(int)) { ProtoWriter.WriteFieldHeader(fieldId, WireType.Variant, writer); ProtoWriter.WriteInt32(_table.GetValue <int>(column.ColumnId, rowId), writer); } else if (column.Type == typeof(short)) { ProtoWriter.WriteFieldHeader(fieldId, WireType.Variant, writer); ProtoWriter.WriteInt16(_table.GetValue <short>(column.ColumnId, rowId), writer); } else if (column.Type == typeof(string)) { ProtoWriter.WriteFieldHeader(fieldId, WireType.String, writer); var value = _table.GetValue <string>(column.ColumnId, rowId); // Console.WriteLine("Writing string {0}", value); ProtoWriter.WriteString(value ?? string.Empty, writer); } else if (column.Type == typeof(bool)) { ProtoWriter.WriteFieldHeader(fieldId, WireType.Variant, writer); ProtoWriter.WriteBoolean(_table.GetValue <bool>(column.ColumnId, rowId), writer); } else if (column.Type == typeof(double)) { ProtoWriter.WriteFieldHeader(fieldId, WireType.Fixed64, writer); ProtoWriter.WriteDouble(_table.GetValue <double>(column.ColumnId, rowId), writer); } else if (column.Type == typeof(long)) { ProtoWriter.WriteFieldHeader(fieldId, WireType.Variant, writer); ProtoWriter.WriteInt64(_table.GetValue <long>(column.ColumnId, rowId), writer); } else if (column.Type == typeof(decimal)) { ProtoWriter.WriteFieldHeader(fieldId, WireType.StartGroup, writer); BclHelpers.WriteDecimal(_table.GetValue <decimal>(column.ColumnId, rowId), writer); } else if (column.Type == typeof(DateTime)) { ProtoWriter.WriteFieldHeader(fieldId, WireType.StartGroup, writer); BclHelpers.WriteDateTime(_table.GetValue <DateTime>(column.ColumnId, rowId), writer); } else if (column.Type == typeof(TimeSpan)) { ProtoWriter.WriteFieldHeader(fieldId, WireType.StartGroup, writer); BclHelpers.WriteTimeSpan(_table.GetValue <TimeSpan>(column.ColumnId, rowId), writer); } else if (column.Type == typeof(Guid)) { ProtoWriter.WriteFieldHeader(fieldId, WireType.StartGroup, writer); BclHelpers.WriteGuid(_table.GetValue <Guid>(column.ColumnId, rowId), writer); } else if (column.Type == typeof(float)) { ProtoWriter.WriteFieldHeader(fieldId, WireType.Fixed32, writer); ProtoWriter.WriteSingle(_table.GetValue <float>(column.ColumnId, rowId), writer); } else if (column.Type == typeof(byte)) { ProtoWriter.WriteFieldHeader(fieldId, WireType.Variant, writer); ProtoWriter.WriteByte(_table.GetValue <byte>(column.ColumnId, rowId), writer); } else if (column.Type == typeof(char)) { ProtoWriter.WriteFieldHeader(fieldId, WireType.Variant, writer); ProtoWriter.WriteInt16((short)_table.GetValue <char>(column.ColumnId, rowId), writer); } }