Exemple #1
0
 //-------------------------------------------------------------------//
 private static object ExcelDateArray2QMinute(Array a)
 {
     var dim1 = a.GetLength(0);
     if (a.Rank == 1)
     {
         var res = new QMinute[dim1];
         for (var i = 0; i < dim1; i++)
             res[i] = (QMinute) ExcelDate2QMinute(a.GetValue(i));
         return res;
     }
     var dim2 = a.GetLength(1);
     var r = new object[dim2]; //two dimensional array
     for (var i = 0; i < dim2; i++)
     {
         var elem = new QMinute[dim1];
         for (var j = 0; j < dim1; j++)
         {
             elem[j] = (QMinute) ExcelDate2QMinute(a.GetValue(j, i));
         }
         r[i] = elem;
     }
     return r;
 }
Exemple #2
0
        private object ReadList(QType qtype)
        {
            _reader.ReadByte(); // attributes
            var length = _reader.ReadInt32();

            switch (qtype)
            {
                case QType.BoolList:
                {
                    var list = new bool[length];
                    for (var i = 0; i < length; i++)
                    {
                        list[i] = _reader.ReadBoolean();
                    }
                    return list;
                }
                case QType.ByteList:
                {
                    var list = new byte[length];
                    for (var i = 0; i < length; i++)
                    {
                        list[i] = _reader.ReadByte();
                    }
                    return list;
                }
                case QType.GuidList:
                {
                    var list = new Guid[length];
                    for (var i = 0; i < length; i++)
                    {
                        list[i] = _reader.ReadGuid();
                    }
                    return list;
                }
                case QType.ShortList:
                {
                    var list = new short[length];
                    for (var i = 0; i < length; i++)
                    {
                        list[i] = _reader.ReadInt16();
                    }
                    return list;
                }
                case QType.IntList:
                {
                    var list = new int[length];
                    for (var i = 0; i < length; i++)
                    {
                        list[i] = _reader.ReadInt32();
                    }
                    return list;
                }
                case QType.LongList:
                {
                    var list = new long[length];
                    for (var i = 0; i < length; i++)
                    {
                        list[i] = _reader.ReadInt64();
                    }
                    return list;
                }
                case QType.FloatList:
                {
                    var list = new float[length];
                    for (var i = 0; i < length; i++)
                    {
                        list[i] = _reader.ReadSingle();
                    }
                    return list;
                }
                case QType.DoubleList:
                {
                    var list = new double[length];
                    for (var i = 0; i < length; i++)
                    {
                        list[i] = _reader.ReadDouble();
                    }
                    return list;
                }
                case QType.String:
                {
                    return _encoding.GetChars(_reader.ReadBytes(length));
                }
                case QType.SymbolList:
                {
                    var list = new string[length];
                    for (var i = 0; i < length; i++)
                    {
                        list[i] = ReadSymbol();
                    }
                    return list;
                }
                case QType.TimestampList:
                {
                    var list = new QTimestamp[length];
                    for (var i = 0; i < length; i++)
                    {
                        list[i] = new QTimestamp(_reader.ReadInt64());
                    }
                    return list;
                }
                case QType.MonthList:
                {
                    var list = new QMonth[length];
                    for (var i = 0; i < length; i++)
                    {
                        list[i] = new QMonth(_reader.ReadInt32());
                    }
                    return list;
                }
                case QType.DateList:
                {
                    var list = new QDate[length];
                    for (var i = 0; i < length; i++)
                    {
                        list[i] = new QDate(_reader.ReadInt32());
                    }
                    return list;
                }
                case QType.DatetimeList:
                {
                    var list = new QDateTime[length];
                    for (var i = 0; i < length; i++)
                    {
                        list[i] = new QDateTime(_reader.ReadDouble());
                    }
                    return list;
                }
                case QType.TimespanList:
                {
                    var list = new QTimespan[length];
                    for (var i = 0; i < length; i++)
                    {
                        list[i] = new QTimespan(_reader.ReadInt64());
                    }
                    return list;
                }
                case QType.MinuteList:
                {
                    var list = new QMinute[length];
                    for (var i = 0; i < length; i++)
                    {
                        list[i] = new QMinute(_reader.ReadInt32());
                    }
                    return list;
                }
                case QType.SecondList:
                {
                    var list = new QSecond[length];
                    for (var i = 0; i < length; i++)
                    {
                        list[i] = new QSecond(_reader.ReadInt32());
                    }
                    return list;
                }
                case QType.TimeList:
                {
                    var list = new QTime[length];
                    for (var i = 0; i < length; i++)
                    {
                        list[i] = new QTime(_reader.ReadInt32());
                    }
                    return list;
                }
            }
            throw new QReaderException("Unable to deserialize q vector of type: " + qtype);
        }
        private object ReadList(QType qtype)
        {
            _reader.ReadByte(); // attributes
            var length = _reader.ReadInt32();

            switch (qtype)
            {
            case QType.BoolList:
            {
                var list = new bool[length];
                for (var i = 0; i < length; i++)
                {
                    list[i] = _reader.ReadBoolean();
                }
                return(list);
            }

            case QType.ByteList:
            {
                var list = new byte[length];
                for (var i = 0; i < length; i++)
                {
                    list[i] = _reader.ReadByte();
                }
                return(list);
            }

            case QType.GuidList:
            {
                var list = new Guid[length];
                for (var i = 0; i < length; i++)
                {
                    list[i] = _reader.ReadGuid();
                }
                return(list);
            }

            case QType.ShortList:
            {
                var list = new short[length];
                for (var i = 0; i < length; i++)
                {
                    list[i] = _reader.ReadInt16();
                }
                return(list);
            }

            case QType.IntList:
            {
                var list = new int[length];
                for (var i = 0; i < length; i++)
                {
                    list[i] = _reader.ReadInt32();
                }
                return(list);
            }

            case QType.LongList:
            {
                var list = new long[length];
                for (var i = 0; i < length; i++)
                {
                    list[i] = _reader.ReadInt64();
                }
                return(list);
            }

            case QType.FloatList:
            {
                var list = new float[length];
                for (var i = 0; i < length; i++)
                {
                    list[i] = _reader.ReadSingle();
                }
                return(list);
            }

            case QType.DoubleList:
            {
                var list = new double[length];
                for (var i = 0; i < length; i++)
                {
                    list[i] = _reader.ReadDouble();
                }
                return(list);
            }

            case QType.String:
            {
                return(_encoding.GetChars(_reader.ReadBytes(length)));
            }

            case QType.SymbolList:
            {
                var list = new string[length];
                for (var i = 0; i < length; i++)
                {
                    list[i] = ReadSymbol();
                }
                return(list);
            }

            case QType.TimestampList:
            {
                var list = new QTimestamp[length];
                for (var i = 0; i < length; i++)
                {
                    list[i] = new QTimestamp(_reader.ReadInt64());
                }
                return(list);
            }

            case QType.MonthList:
            {
                var list = new QMonth[length];
                for (var i = 0; i < length; i++)
                {
                    list[i] = new QMonth(_reader.ReadInt32());
                }
                return(list);
            }

            case QType.DateList:
            {
                var list = new QDate[length];
                for (var i = 0; i < length; i++)
                {
                    list[i] = new QDate(_reader.ReadInt32());
                }
                return(list);
            }

            case QType.DatetimeList:
            {
                var list = new QDateTime[length];
                for (var i = 0; i < length; i++)
                {
                    list[i] = new QDateTime(_reader.ReadDouble());
                }
                return(list);
            }

            case QType.TimespanList:
            {
                var list = new QTimespan[length];
                for (var i = 0; i < length; i++)
                {
                    list[i] = new QTimespan(_reader.ReadInt64());
                }
                return(list);
            }

            case QType.MinuteList:
            {
                var list = new QMinute[length];
                for (var i = 0; i < length; i++)
                {
                    list[i] = new QMinute(_reader.ReadInt32());
                }
                return(list);
            }

            case QType.SecondList:
            {
                var list = new QSecond[length];
                for (var i = 0; i < length; i++)
                {
                    list[i] = new QSecond(_reader.ReadInt32());
                }
                return(list);
            }

            case QType.TimeList:
            {
                var list = new QTime[length];
                for (var i = 0; i < length; i++)
                {
                    list[i] = new QTime(_reader.ReadInt32());
                }
                return(list);
            }
            }
            throw new QReaderException("Unable to deserialize q vector of type: " + qtype);
        }