public static void CopyData(VirtualArray src, VirtualIndex srcIndex, VirtualArray dst, VirtualIndex dstIndex, int count, bool allowExpantion) { if (src == null || dst == null || srcIndex == null || dstIndex == null) { return; } if (src.Size < srcIndex.IndexValue) { throw new IndexOutOfRangeException(); } srcIndex = srcIndex.Clone(); dstIndex = dstIndex.Clone(); while (count > 0) { Array arr = src._baseArray[srcIndex.YIndex] as Array; int copyCount = maxSize - srcIndex.XIndex; if (copyCount > count) { copyCount = count; } Array dstArr = null; if (dst._baseArray.Count > dstIndex.YIndex) { dstArr = dst._baseArray[dstIndex.YIndex] as Array; } int accomdateble = (maxSize - dstIndex.XIndex); if (accomdateble > copyCount) { accomdateble = copyCount; } if ((dstArr == null || accomdateble > (dstArr.Length - dstIndex.XIndex)) && allowExpantion) { if (dstArr == null) { //if (count - accomdateble >= 0) // dstArr = new byte[maxSize]; //else dstArr = new byte[accomdateble]; dst._baseArray.Add(dstArr); } else { byte[] tmpArray = new byte[accomdateble + dstArr.Length - (dstArr.Length - dstIndex.XIndex)]; Buffer.BlockCopy(dstArr, 0, tmpArray, 0, dstArr.Length); dstArr = tmpArray; dst._baseArray[dstIndex.YIndex] = dstArr; } } Buffer.BlockCopy(arr, srcIndex.XIndex, dstArr, dstIndex.XIndex, accomdateble); count -= accomdateble; srcIndex.IncrementBy(accomdateble); dstIndex.IncrementBy(accomdateble); } }
public static void CopyData(VirtualArray src, VirtualIndex srcIndex, VirtualArray dst, VirtualIndex dstIndex, int count) { CopyData(src, srcIndex, dst, dstIndex, count, false); }