Beispiel #1
0
        public T Get <T>(int recno) where T : class, new()                            // new from 1.3 version
        {
            DbfRow row = this.GetRow(recno);

            T t = (T)Activator.CreateInstance(typeof(T), row);

            return(t);
        }
Beispiel #2
0
 public void Dispose()
 {
     if (!disposed)
     {
         disposed = true;
         this.stream.Dispose();
         _row = null;
     }
 }
Beispiel #3
0
        //

        public static T Get <T>(DbfRow row) where T : class, new()                     // new from 1.3 version
        {
            if (row == null)
            {
                return(null);
            }

            T t = (T)Activator.CreateInstance(typeof(T), row);

            return(t);
        }
Beispiel #4
0
        // http://stackoverflow.com/questions/1852837/is-there-a-generic-constructor-with-parameter-constraint-in-c
        // http://stackoverflow.com/questions/700966/generic-type-in-constructor

        public T Read <T>() where T : class, new()                    // new from 1.3 version
        {
            do
            {
                row_ = dbfTable.GetRow(nextRecNo, false);                                     // Don't throw an exception, returns null if record not found

                nextRecNo++;
            } while (skipDeleted && (row_ != null) && row_.deleted);

            return(DbfTable.Get <T>(row_));
        }
Beispiel #5
0
        public bool Read()
        {
            do
            {
                row_ = dbfTable.GetRow(nextRecNo, false);                                     // Don't throw an exception, returns null if record not found

                nextRecNo++;
            } while (skipDeleted && (row_ != null) && row_.deleted);

            return(row_ != null);
        }
Beispiel #6
0
        public void SetSkipDeleted(bool newValue)
        {
            if (_row != null)
            {
                if (_row.deleted && newValue)
                {
                    _row = null;                                                  // there isn't selected row  already
                }
            }

            _skipDeleted = newValue;
        }
Beispiel #7
0
        private DbfRow GetRow(int dbfRecNo)
        {
            if (dbfRecNo < 1)
            {                // '< 1' because recno rule as dbase/index rule
                _row = null; // don't found
            }
            else
            {
                _row = _dbfTable.GetRow(dbfRecNo - 1, false);
            }

            return(_row);
        }
Beispiel #8
0
        public IEnumerator <T> GetEnumerator()
        {
            for (int i = firstRecNo; (i <= lastRecNo); i++)
            {
                DbfRow row = table.GetRow(i);

                if (this.skipDeleted && row.deleted)
                {
                    continue;
                }

                yield return(row.Get <T>());
            }
        }
Beispiel #9
0
        public IEnumerator <T> GetEnumerator <T>(bool skipDeleted) where T : class, new()
        {
            for (int i = 0; i < this.recCount; i++)
            {
                DbfRow row = this.GetRow(i);

                if (skipDeleted && row.deleted)
                {
                    continue;
                }

                yield return(DbfTable.Get <T>(row));
            }
        }
Beispiel #10
0
        private bool MarchingOne(bool forward)
        {
            if (eof)
            {
                return(false);
            }

            //

            int direction = forward ? 1 : -1;

            do
            {
                _row = _dbfTable.GetRow(_row.recNo + direction, false);                 // Don't throw an exception, returns null if record not found
            } while (skipDeleted && (_row != null) && _row.deleted);

            return(_row != null);
        }