private void Source_DatumReplaced(int srcIndex, IDatum datum) { using (Lock()) { bool wasIncluded = m_mapper.IsSelected(srcIndex); if (wasIncluded) { int ndx = m_mapper.FromSourceIndex(srcIndex); m_mapper.OnSourceItemReplaced(srcIndex, datum); if (m_mapper.Filter(datum)) { DatumReplaced?.Invoke(ndx, datum); } else { DatumDeleted?.Invoke(ndx); } } else { m_mapper.OnSourceItemReplaced(srcIndex, datum); if (m_mapper.Filter(datum)) { int ndx = m_mapper.FromSourceIndex(srcIndex); DatumInserted?.Invoke(ndx, datum); } } } }
void DataProvider_DatumInserted(int ndx, IDatum datum) { T key = m_selector(datum); lock (m_ndxTable) { List <int> lst; if (!m_ndxTable.TryGetValue(key, out lst)) { lst = new List <int>(); m_ndxTable[key] = lst; } //datum inserted not at the end => adjust indicies if (ndx < m_dataProvider.Count - 1) { foreach (List <int> l in m_ndxTable.Values) { for (int i = 0; i < lst.Count; i++) { if (ndx <= l[i]) { ++l[i]; } } } } lst.Add(ndx); DatumInserted?.Invoke(datum); } }
void Source_DatumReplaced(int srcIndex, IDataRow datum) { Assert(datum != null); bool wasIncluded = m_mapper.Accepted(srcIndex); if (wasIncluded) { int ndx = m_mapper.FromSourceIndex(srcIndex); m_mapper.OnSourceItemReplaced(srcIndex, datum); if (m_mapper.Filter(datum)) { DatumReplaced?.Invoke(ndx, datum); } else { DatumDeleted?.Invoke(ndx); } } else { m_mapper.OnSourceItemReplaced(srcIndex, datum); if (m_mapper.Filter(datum)) { int ndx = m_mapper.FromSourceIndex(srcIndex); DatumInserted?.Invoke(ndx, datum); } } }
public void Insert(IDatum item) { Assert(IsConnected); m_impCountries.Add(item as IDataRow); DatumInserted?.Invoke(Count - 1, item); }
void OnDatumReplaced(int xsDatum, IDatum datum) { bool wasIncluded = m_mapper.Accepted(xsDatum); if (wasIncluded) { int xdItem = m_mapper.FromSourceIndex(xsDatum); m_mapper.OnSourceItemReplaced(xsDatum, datum); if (m_mapper.Filter(datum)) { DatumReplaced?.Invoke(xdItem, datum); } else { DatumDeleted?.Invoke(xdItem); } } else { m_mapper.OnSourceItemReplaced(xsDatum, datum); if (m_mapper.Filter(datum)) { int xdItem = m_mapper.FromSourceIndex(xsDatum); DatumInserted?.Invoke(xdItem, datum); } } }
public void Insert(T datum) { Assert(IsConnected); Assert(datum != null); lock (m_rwLock) { int ndxFrame = m_header.FirstDeletedFrameIndex == NULL_INDEX ? m_header.FrameCount : m_header.FirstDeletedFrameIndex; if (m_recycledData.Count > 0) { m_recycledData.RemoveAt(m_recycledData.BinarySearch(ndxFrame)); long framePos = GetFramePosition(ndxFrame); if (m_recycledData.Count > 0) { ReadFrame(framePos); m_reader.Position = 0; m_header.FirstDeletedFrameIndex = m_reader.ReadInt(); } else { m_header.FirstDeletedFrameIndex = NULL_INDEX; } m_writer.Position = 0; datum.Write(m_writer); WriteFrame(framePos); } else { m_writer.Position = 0; datum.Write(m_writer); long framePos = GetFramePosition(ndxFrame); WriteFrame(framePos); ++m_header.FrameCount; } m_header.LastWriteTime = DateTime.Now; int ndxRow = FrameIndexToRowIndex(ndxFrame); DatumInserted?.Invoke(ndxRow, datum); } }
public void Insert(IDatum item) { Assert(IsConnected); Assert(item is T); lock (m_table) { int ndx = m_table.Insert((T)item); if (AutoFlush) { m_table.Flush(); } DatumInserted?.Invoke(ndx, item); } }
private void Source_DatumInserted(int ndx, IDatum datum) { Assert(!m_ndxTable.ContainsKey(datum.ID)); Monitor.Enter(m_lock); var keys = from kv in m_ndxTable where kv.Value >= ndx select kv.Key; keys.ToList().ForEach(k => ++ m_ndxTable[k]); m_ndxTable.Add(datum.ID, ndx); Monitor.Exit(m_lock); DatumInserted?.Invoke(datum); }
void DataProvider_DatumInserted(int ndxDatum, IDatum datum) { var row = datum as IDataRow; Debug.Assert(!m_ndxTable.ContainsKey(row.ID)); lock (m_ndxTable) { var keys = from kv in m_ndxTable where kv.Value >= ndxDatum select kv.Key; keys.ToList().ForEach(k => ++ m_ndxTable[k]); m_ndxTable.Add(row.ID, ndxDatum); } DatumInserted?.Invoke(row); }
void OnRowInserted(int ndx, IDatum row) { DatumInserted?.Invoke(ndx, row); }
void Table_DatumInserted(int ndx, T datum) => DatumInserted?.Invoke(ndx, datum);