Exemplo n.º 1
0
        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);
                }
            }
        }
Exemplo n.º 2
0
        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);
                    }
                }
            }
        }
Exemplo n.º 3
0
            public void Replace(int ndx, IDatum item)
            {
                Assert(IsConnected);
                Assert(item is T);
                Assert(ndx >= 0 && ndx < Count);

                lock (m_table)
                {
                    Action <int, IDatum> handler = DatumReplacing;

                    if (handler != null)
                    {
                        IDatum oldDatum = m_table.Get(ndx);
                        handler(ndx, item);
                    }

                    ndx = m_table.Replace(ndx, (T)item);

                    if (AutoFlush)
                    {
                        m_table.Flush();
                    }

                    DatumReplaced?.Invoke(ndx, item);
                }
            }
Exemplo n.º 4
0
        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);
                }
            }
        }
Exemplo n.º 5
0
        private void Source_DatumReplaced(int ndx, IDatum datum)
        {
            Assert(m_ndxTable.ContainsKey(datum.ID));
            Assert(m_ndxTable[datum.ID] == ndx);
            Assert(m_cache.ContainsKey(ndx));

            //IDatum.ID is immutable => juste remove from cache

            Monitor.Enter(m_lock);
            m_cache.Remove(ndx);
            Monitor.Exit(m_lock);

            DatumReplaced?.Invoke(datum);
        }
Exemplo n.º 6
0
        void DataProvider_DatumReplaced(int ndxDatum, IDatum datum)
        {
            var d = datum as IDataRow;

            Debug.Assert(m_ndxTable.ContainsKey(d.ID));
            Debug.Assert(m_ndxTable[d.ID] == ndxDatum);
            Debug.Assert(m_cache != null);
            Debug.Assert(m_cache.ContainsKey(ndxDatum));

            lock (m_ndxTable)
            {
                m_cache.Remove(ndxDatum);
            }

            DatumReplaced?.Invoke(d);
        }
Exemplo n.º 7
0
        void DataProvider_DatumReplaced(int ndx, IDatum datum)
        {
            IDatum oldDatum = null;

            lock (m_cache)
            {
                for (int i = 0; i < m_cache.Count; i++)
                {
                    if (m_cache[i].Item1 == ndx)
                    {
                        oldDatum = m_cache[i].Item2;
                        m_cache.RemoveAt(i);
                        break;
                    }
                }
            }

            Debug.Assert(oldDatum != null);

            T oldKey = m_selector(oldDatum);
            T newKey = m_selector(datum);

            if (!m_ndxTable.Comparer.Equals(oldKey, newKey))
            {
                lock (m_ndxTable)
                {
                    m_ndxTable[oldKey].Remove(ndx);

                    List <int> lst;

                    if (!m_ndxTable.TryGetValue(newKey, out lst))
                    {
                        lst = new List <int>();
                        m_ndxTable[newKey] = lst;
                    }

                    lst.Add(ndx);
                }
            }


            DatumReplaced?.Invoke(datum);
        }
Exemplo n.º 8
0
        public void Replace(int ndx, T datum)
        {
            Assert(IsConnected);
            Assert(ndx < RowCount);
            Assert(0 <= ndx);
            Assert(datum != null);

            lock (m_rwLock)
            {
                m_writer.Position = 0;
                datum.Write(m_writer);

                int  ndxFrame = RowIndexToFrameIndex(ndx);
                long framePos = GetFramePosition(ndxFrame);
                WriteFrame(framePos);

                m_header.LastWriteTime = DateTime.Now;
                DatumReplaced?.Invoke(ndx, datum);
            }
        }
Exemplo n.º 9
0
        private void DataProvider_DatumReplaced(int ndx, IDatum datum)
        {
            using (Lock())
            {
                IDatum oldDatum = null;

                for (int i = 0; i < m_cache.Count; ++i)
                {
                    if (m_cache[i].Item1 == ndx)
                    {
                        oldDatum = m_cache[i].Item2;
                        m_cache.RemoveAt(i);
                        break;
                    }
                }

                Assert(oldDatum != null);

                T oldKey = m_selector(oldDatum);
                T newKey = m_selector(datum);

                if (!m_dataIndices.Comparer.Equals(oldKey, newKey))
                {
                    m_dataIndices[oldKey].Remove(ndx);
                }

                List <int> lst;

                if (!m_dataIndices.TryGetValue(newKey, out lst))
                {
                    lst = new List <int>();
                    m_dataIndices[newKey] = lst;
                }

                lst.Add(ndx);

                DatumReplaced?.Invoke(datum);
            }
        }
Exemplo n.º 10
0
 void OnRowReplaced(int ndx, IDatum row)
 {
     DatumReplaced?.Invoke(ndx, row);
 }
Exemplo n.º 11
0
 void Table_DatumReplaced(int ndx, T datum) => DatumReplaced?.Invoke(ndx, datum);