internal static int GetChars(NativeBuffer buffer, int valueOffset, int lengthOffset, MetaType metaType, OracleConnection connection, bool boundAsUCS2, int sourceOffset, char[] destinationBuffer, int destinationOffset, int charCount)
        {
            bool success = false;

            RuntimeHelpers.PrepareConstrainedRegions();
            try
            {
                buffer.DangerousAddRef(ref success);
                if (boundAsUCS2)
                {
                    if (!metaType.IsLong)
                    {
                        Marshal.Copy(buffer.DangerousGetDataPtrWithBaseOffset(valueOffset + (System.Data.Common.ADP.CharSize * sourceOffset)), destinationBuffer, destinationOffset, charCount);
                        return(charCount);
                    }
                    NativeBuffer_LongColumnData.CopyOutOfLineChars(buffer.ReadIntPtr(valueOffset), sourceOffset, destinationBuffer, destinationOffset, charCount);
                    return(charCount);
                }
                string str    = MarshalToString(buffer, valueOffset, lengthOffset, metaType, connection, boundAsUCS2, false);
                int    length = str.Length;
                int    num    = ((sourceOffset + charCount) > length) ? (length - sourceOffset) : charCount;
                Buffer.BlockCopy(str.ToCharArray(sourceOffset, num), 0, destinationBuffer, destinationOffset * System.Data.Common.ADP.CharSize, num * System.Data.Common.ADP.CharSize);
                charCount = num;
            }
            finally
            {
                if (success)
                {
                    buffer.DangerousRelease();
                }
            }
            return(charCount);
        }
Ejemplo n.º 2
0
        internal void Rebind(OracleConnection connection, ref bool mustRelease, ref SafeHandle handleToBind)
        {
            handleToBind = null;
            switch (this._metaType.OciType)
            {
            case OCI.DATATYPE.CLOB:
            case OCI.DATATYPE.BLOB:
            case OCI.DATATYPE.BFILE:
                OciLobLocator.SafeDispose(ref this._lobLocator);
                this._lobLocator = new OciLobLocator(connection, this._metaType.OracleType);
                handleToBind     = this._lobLocator.Descriptor;
                break;

            case OCI.DATATYPE.LONGRAW:
            case OCI.DATATYPE.LONG:
                this._rowBuffer.WriteInt32(this._lengthOffset, 0);
                this._longLength = -1;
                if (this._longBuffer != null)
                {
                    this._longBuffer.Reset();
                }
                else
                {
                    this._longBuffer = new NativeBuffer_LongColumnData();
                }
                handleToBind = this._longBuffer;
                break;
            }
            if (handleToBind != null)
            {
                handleToBind.DangerousAddRef(ref mustRelease);
                this._rowBuffer.WriteIntPtr(this._valueOffset, handleToBind.DangerousGetHandle());
            }
        }
Ejemplo n.º 3
0
 internal static void SafeDispose(ref NativeBuffer_LongColumnData handle)
 {
     if (handle != null)
     {
         handle.Dispose();
     }
     handle = null;
 }
 internal static int GetBytes(NativeBuffer buffer, int valueOffset, MetaType metaType, int sourceOffset, byte[] destinationBuffer, int destinationOffset, int byteCount)
 {
     if (!metaType.IsLong)
     {
         buffer.ReadBytes(valueOffset + sourceOffset, destinationBuffer, destinationOffset, byteCount);
         return(byteCount);
     }
     NativeBuffer_LongColumnData.CopyOutOfLineBytes(buffer.ReadIntPtr(valueOffset), sourceOffset, destinationBuffer, destinationOffset, byteCount);
     return(byteCount);
 }
        internal static string MarshalToString(NativeBuffer buffer, int valueOffset, int lengthOffset, MetaType metaType, OracleConnection connection, bool boundAsUCS2, bool outputParameterBinding)
        {
            string str;
            int    length = GetLength(buffer, lengthOffset, metaType);

            if (boundAsUCS2 && outputParameterBinding)
            {
                length /= 2;
            }
            bool flag = metaType.IsLong && !outputParameterBinding;

            if (boundAsUCS2)
            {
                if (flag)
                {
                    byte[] destinationBuffer = new byte[length * System.Data.Common.ADP.CharSize];
                    NativeBuffer_LongColumnData.CopyOutOfLineBytes(buffer.ReadIntPtr(valueOffset), 0, destinationBuffer, 0, length * System.Data.Common.ADP.CharSize);
                    str = Encoding.Unicode.GetString(destinationBuffer);
                }
                else
                {
                    str = buffer.PtrToStringUni(valueOffset, length);
                }
            }
            else
            {
                byte[] buffer2;
                if (flag)
                {
                    buffer2 = new byte[length];
                    NativeBuffer_LongColumnData.CopyOutOfLineBytes(buffer.ReadIntPtr(valueOffset), 0, buffer2, 0, length);
                }
                else
                {
                    buffer2 = buffer.ReadBytes(valueOffset, length);
                }
                str = connection.GetString(buffer2, metaType.UsesNationalCharacterSet);
            }
            GC.KeepAlive(buffer);
            return(str);
        }
 internal static void SafeDispose(ref NativeBuffer_LongColumnData handle)
 {
     if (handle != null)
     {
         handle.Dispose();
     }
     handle = null;
 }