示例#1
0
        public ArrayImpl SplitBinaryData(BinaryDataContext data, long size)
        {
            if (size <= 0 || size > Int32.MaxValue)
            {
                throw RuntimeException.InvalidNthArgumentValue(2);
            }

            ArrayImpl array    = new ArrayImpl();
            long      dataSize = data.Size();

            if (dataSize < size)
            {
                array.Add(data);
                return(array);
            }

            int readedBytes = 0;
            var dataStream  = data.GetStream();

            while (readedBytes < dataSize)
            {
                int bytesToRead = (int)size;
                if (bytesToRead > dataSize - readedBytes)
                {
                    bytesToRead = (int)(dataSize - readedBytes);
                }

                byte[] buffer = new byte[bytesToRead];
                dataStream.Read(buffer, 0, bytesToRead);
                readedBytes += bytesToRead;
                array.Add(new BinaryDataContext(buffer));
            }

            return(array);
        }
示例#2
0
 public string TimeZonePresentation(string id)
 {
     try
     {
         return(TimeZoneConverter.TimeZonePresentation(id));
     }
     catch (TimeZoneNotFoundException)
     {
         throw RuntimeException.InvalidNthArgumentValue(1);
     }
 }
示例#3
0
 public int StandardTimeOffset(string timeZone = null, IValue universalTime = null)
 {
     try
     {
         return(TimeZoneConverter.StandardTimeOffset(timeZone, universalTime?.AsDate()));
     }
     catch (TimeZoneNotFoundException)
     {
         throw RuntimeException.InvalidNthArgumentValue(1);
     }
 }
示例#4
0
 public IValue ToUniversalTime(IValue localTime, string timeZone = null)
 {
     try
     {
         var dt = TimeZoneConverter.ToUniversalTime(localTime.AsDate(), timeZone);
         return(ValueFactory.Create(dt));
     }
     catch (TimeZoneNotFoundException)
     {
         throw RuntimeException.InvalidNthArgumentValue(2);
     }
 }
示例#5
0
        public void Move(IValue row, int offset)
        {
            int index_source = IndexByValue(row);

            int index_dest = index_source + offset;

            if (index_dest < 0 || index_dest >= _rows.Count())
            {
                throw RuntimeException.InvalidNthArgumentValue(2);
            }

            ValueTableRow tmp = _rows[index_source];

            if (index_source < index_dest)
            {
                _rows.Insert(index_dest + 1, tmp);
                _rows.RemoveAt(index_source);
            }
            else
            {
                _rows.RemoveAt(index_source);
                _rows.Insert(index_dest, tmp);
            }
        }
示例#6
0
        public static ArrayImpl Constructor(IValue[] dimensions)
        {
            if (dimensions.Length == 1 && dimensions[0].GetRawValue() is FixedArrayImpl)
            {
                return(Constructor(dimensions[0]));
            }

            ArrayImpl cloneable = null;

            for (int dim = dimensions.Length - 1; dim >= 0; dim--)
            {
                if (dimensions[dim] == null)
                {
                    throw RuntimeException.InvalidNthArgumentType(dim + 1);
                }

                int bound = (int)dimensions[dim].AsNumber();
                if (bound <= 0)
                {
                    throw RuntimeException.InvalidNthArgumentValue(dim + 1);
                }

                var newInst = new ArrayImpl();
                FillArray(newInst, bound);
                if (cloneable != null)
                {
                    for (int i = 0; i < bound; i++)
                    {
                        newInst._values[i] = CloneArray(cloneable);
                    }
                }
                cloneable = newInst;
            }

            return(cloneable);
        }
示例#7
0
        public void Move(IValue item, int offset)
        {
            int index_source = IndexByValue(item);

            int index_dest = index_source + offset;

            if (index_dest < 0 || index_dest >= _items.Count())
            {
                throw RuntimeException.InvalidNthArgumentValue(2);
            }

            ValueListItem itemObject = _items[index_source];

            if (index_source < index_dest)
            {
                _items.Insert(index_dest + 1, itemObject);
                _items.RemoveAt(index_source);
            }
            else
            {
                _items.RemoveAt(index_source);
                _items.Insert(index_dest, itemObject);
            }
        }