+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-////////////////////////////////////////////////////////////////////////////////
-// Void
-// This class represents a Missing Variant
-////////////////////////////////////////////////////////////////////////////////
-
-using System;
-using System.Runtime.Remoting;
-using System.Runtime.Serialization;
-
-namespace System
-{
- [Serializable]
- public sealed class DBNull : ISerializable, IConvertible
- {
- //Package private constructor
- private DBNull()
- {
- }
-
- private DBNull(SerializationInfo info, StreamingContext context)
- {
- throw new NotSupportedException(SR.NotSupported_DBNullSerial);
- }
-
- public static readonly DBNull Value = new DBNull();
-
- public void GetObjectData(SerializationInfo info, StreamingContext context)
- {
- UnitySerializationHolder.GetUnitySerializationInfo(info, UnitySerializationHolder.NullUnity, null, null);
- }
-
- public override String ToString()
- {
- return String.Empty;
- }
-
- public String ToString(IFormatProvider provider)
- {
- return String.Empty;
- }
-
- public TypeCode GetTypeCode()
- {
- return TypeCode.DBNull;
- }
-
- /// <internalonly/>
- bool IConvertible.ToBoolean(IFormatProvider provider)
- {
- throw new InvalidCastException(SR.InvalidCast_FromDBNull);
- }
-
- /// <internalonly/>
- char IConvertible.ToChar(IFormatProvider provider)
- {
- throw new InvalidCastException(SR.InvalidCast_FromDBNull);
- }
-
- /// <internalonly/>
- sbyte IConvertible.ToSByte(IFormatProvider provider)
- {
- throw new InvalidCastException(SR.InvalidCast_FromDBNull);
- }
-
- /// <internalonly/>
- byte IConvertible.ToByte(IFormatProvider provider)
- {
- throw new InvalidCastException(SR.InvalidCast_FromDBNull);
- }
-
- /// <internalonly/>
- short IConvertible.ToInt16(IFormatProvider provider)
- {
- throw new InvalidCastException(SR.InvalidCast_FromDBNull);
- }
-
- /// <internalonly/>
- ushort IConvertible.ToUInt16(IFormatProvider provider)
- {
- throw new InvalidCastException(SR.InvalidCast_FromDBNull);
- }
-
- /// <internalonly/>
- int IConvertible.ToInt32(IFormatProvider provider)
- {
- throw new InvalidCastException(SR.InvalidCast_FromDBNull);
- }
-
- /// <internalonly/>
- uint IConvertible.ToUInt32(IFormatProvider provider)
- {
- throw new InvalidCastException(SR.InvalidCast_FromDBNull);
- }
-
- /// <internalonly/>
- long IConvertible.ToInt64(IFormatProvider provider)
- {
- throw new InvalidCastException(SR.InvalidCast_FromDBNull);
- }
-
- /// <internalonly/>
- ulong IConvertible.ToUInt64(IFormatProvider provider)
- {
- throw new InvalidCastException(SR.InvalidCast_FromDBNull);
- }
-
- /// <internalonly/>
- float IConvertible.ToSingle(IFormatProvider provider)
- {
- throw new InvalidCastException(SR.InvalidCast_FromDBNull);
- }
-
- /// <internalonly/>
- double IConvertible.ToDouble(IFormatProvider provider)
- {
- throw new InvalidCastException(SR.InvalidCast_FromDBNull);
- }
-
- /// <internalonly/>
- decimal IConvertible.ToDecimal(IFormatProvider provider)
- {
- throw new InvalidCastException(SR.InvalidCast_FromDBNull);
- }
-
- /// <internalonly/>
- DateTime IConvertible.ToDateTime(IFormatProvider provider)
- {
- throw new InvalidCastException(SR.InvalidCast_FromDBNull);
- }
-
- /// <internalonly/>
- Object IConvertible.ToType(Type type, IFormatProvider provider)
- {
- return Convert.DefaultToType((IConvertible)this, type, provider);
- }
- }
-}
-
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal unsafe extern void ReplaceBufferAnsiInternal(sbyte* newBuffer, int newLength);
+
+ // Copies the source StringBuilder to the destination IntPtr memory allocated with len bytes.
+ internal unsafe void InternalCopy(IntPtr dest, int len)
+ {
+ if (len == 0)
+ return;
+
+ bool isLastChunk = true;
+ byte* dstPtr = (byte*)dest.ToPointer();
+ StringBuilder currentSrc = FindChunkForByte(len);
+
+ do
+ {
+ int chunkOffsetInBytes = currentSrc.m_ChunkOffset * sizeof(char);
+ int chunkLengthInBytes = currentSrc.m_ChunkLength * sizeof(char);
+ fixed (char* charPtr = ¤tSrc.m_ChunkChars[0])
+ {
+ byte* srcPtr = (byte*)charPtr;
+ if (isLastChunk)
+ {
+ isLastChunk = false;
+ Buffer.Memcpy(dstPtr + chunkOffsetInBytes, srcPtr, len - chunkOffsetInBytes);
+ }
+ else
+ {
+ Buffer.Memcpy(dstPtr + chunkOffsetInBytes, srcPtr, chunkLengthInBytes);
+ }
+ }
+ currentSrc = currentSrc.m_ChunkPrevious;
+ } while (currentSrc != null);
+ }
}
}