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); }
public string TimeZonePresentation(string id) { try { return(TimeZoneConverter.TimeZonePresentation(id)); } catch (TimeZoneNotFoundException) { throw RuntimeException.InvalidNthArgumentValue(1); } }
public int StandardTimeOffset(string timeZone = null, IValue universalTime = null) { try { return(TimeZoneConverter.StandardTimeOffset(timeZone, universalTime?.AsDate())); } catch (TimeZoneNotFoundException) { throw RuntimeException.InvalidNthArgumentValue(1); } }
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); } }
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); } }
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); }
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); } }