Example #1
0
        public T Next()
        {
            InitializeList();


            this._readerPosition++;

            if (this._readerPosition > this._keyList.Count - 1)
            {
                TryExtendEnd();
            }

            T ret = default(T);

            while (ret == null)
            {
                CsvPimaryKey key = this._keyList[this._readerPosition];
                IRestriction r   = RestrictionFactory.CsvKeyRestriction(typeof(T), key);

                ret = this._serializer.Connector.Load <T>(r);

                if (ret == null)
                {
                    _readerPosition++;
                }
            }

            return(ret);
        }
Example #2
0
        public IList <CsvPimaryKey> GetCSVKeys(Type type, String sqlString, ISerializerTransaction transaction)
        {
            List <CsvPimaryKey> ret = new List <CsvPimaryKey>();


            if (this._ipro != null)
            {
                this._ipro.InternalTotal = this.count(type, sqlString);
            }
            DbDataReader reader = CreateDataReader(type, sqlString, transaction);

            while (reader.Read())
            {
                CsvPimaryKey key = new CsvPimaryKey(type, reader, Target);
                ret.Add(key);

                if (this._ipro != null)
                {
                    this._ipro.advance();
                    if (this._ipro.IsCancelRequested)
                    {
                        break;
                    }
                }
            }

            reader.Close();
            return(ret);
        }
Example #3
0
 public int IndexOf(T iso)
 {
     try
     {
         CsvPimaryKey tmp = new CsvPimaryKey(iso, _serializer.Target);
         return(_keys.IndexOf(tmp));
     }
     catch (Exception)
     {
         return(-1);
     }
 }
Example #4
0
        public void SetIteratorTo(T t)
        {
            InitializeList();
            TryExtendEnd();

            CsvPimaryKey key = new CsvPimaryKey(t, this._serializer.Target);

            int i = 0;

            foreach (CsvPimaryKey csv in this._keyList)
            {
                if (key.Equals(csv))
                {
                    this._readerPosition = i;
                    return;
                }
                i++;
            }
        }
Example #5
0
        public T Prev()
        {
            InitializeList();

            this._readerPosition--;

            T ret = default(T);

            while (ret == null)
            {
                CsvPimaryKey key = this._keyList[this._readerPosition];
                IRestriction r   = RestrictionFactory.CsvKeyRestriction(typeof(T), key);

                ret = this._serializer.Connector.Load <T>(r);

                if (ret == null)
                {
                    _readerPosition--;
                }
            }

            return(ret);
        }
Example #6
0
        public int CurrentPosition()
        {
            int position = -1;

            T ret = default(T);

            try
            {
                CsvPimaryKey key1     = this._keyList[this._readerPosition];
                IRestriction restrict = RestrictionFactory.CsvKeyRestriction(typeof(T), key1);
                ret = this._serializer.Connector.Load <T>(restrict);
            }
            catch (ArgumentOutOfRangeException)
            {
                return(0);
            }

            foreach (CsvPimaryKey key in this._keyList)
            {
                IRestriction r = RestrictionFactory.CsvKeyRestriction(typeof(T), key);

                T tmp = this._serializer.Connector.Load <T>(r);

                if (tmp != null)
                {
                    position++;

                    if (tmp.Equals(ret))
                    {
                        return(position + 1);
                    }
                }
            }

            return(0);
        }
Example #7
0
 public static IRestriction CsvKeyRestriction(Type type, CsvPimaryKey csvKey)
 {
     return(new CsvKeyRestriction(type, csvKey));
 }
Example #8
0
 public CsvKeyRestriction(Type type, CsvPimaryKey csvKey)
 {
     _csvKey = csvKey;
     _type   = type;
 }