コード例 #1
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);
                    }
                }
            }
        }
コード例 #2
0
ファイル: AttrIndexer.cs プロジェクト: Adel-dz/Hub
        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);
            }
        }
コード例 #3
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);
                }
            }
        }
コード例 #4
0
ファイル: PreviewPage.cs プロジェクト: Adel-dz/Hub
            public void Insert(IDatum item)
            {
                Assert(IsConnected);

                m_impCountries.Add(item as IDataRow);
                DatumInserted?.Invoke(Count - 1, item);
            }
コード例 #5
0
ファイル: DatumProvider.cs プロジェクト: Adel-dz/Hub
        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);
                }
            }
        }
コード例 #6
0
ファイル: DBTable.cs プロジェクト: Adel-dz/Hub
        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);
            }
        }
コード例 #7
0
            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);
                }
            }
コード例 #8
0
ファイル: KeyIndexer.cs プロジェクト: Adel-dz/Tarif
        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);
        }
コード例 #9
0
        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);
        }
コード例 #10
0
ファイル: DataTable.RowProvider.cs プロジェクト: Adel-dz/Hub
 void OnRowInserted(int ndx, IDatum row)
 {
     DatumInserted?.Invoke(ndx, row);
 }
コード例 #11
0
 void Table_DatumInserted(int ndx, T datum) => DatumInserted?.Invoke(ndx, datum);