コード例 #1
0
 internal string PtrToString(NativeBuffer buf)
 {
     if (this.IsUnicode)
     {
         return(buf.PtrToStringUni(0));
     }
     return(buf.PtrToStringAnsi(0));
 }
コード例 #2
0
        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);
        }