示例#1
0
        public override int CopyTo(int sourceOffset, PageCursor targetCursor, int targetOffset, int lengthInBytes)
        {
            int sourcePageSize = CurrentPageSize;
            int targetPageSize = targetCursor.CurrentPageSize;

            if (targetCursor.GetType() != typeof(MuninnWritePageCursor))
            {
                throw new System.ArgumentException("Target cursor must be writable");
            }
            if (sourceOffset >= 0 & targetOffset >= 0 & sourceOffset < sourcePageSize & targetOffset < targetPageSize & lengthInBytes >= 0)
            {
                MuninnPageCursor cursor = ( MuninnPageCursor )targetCursor;
                int remainingSource     = sourcePageSize - sourceOffset;
                int remainingTarget     = targetPageSize - targetOffset;
                int bytes = Math.Min(lengthInBytes, Math.Min(remainingSource, remainingTarget));
                UnsafeUtil.copyMemory(_pointer + sourceOffset, cursor._pointer + targetOffset, bytes);
                return(bytes);
            }
            _outOfBounds = true;
            return(0);
        }