Esempio n. 1
0
        public override long GetBytes(int i, long fieldOffset, byte[] buffer, int bufferoffset, int length)
        {
            this.CheckNull(i);
            if (this._rResult.MetaData.ColumnTypes[i].TypeCode == 30)
            {
                BlobDataId id = this.GetColumnInType(i, this._rResult.MetaData.ColumnTypes[i]) as BlobDataId;
                if (id == null)
                {
                    throw new InvalidCastException();
                }
                ISessionInterface sessionProxy = this._command.Connection.InnerConnection.SessionProxy;
                long num2 = id.Length(sessionProxy);
                if (buffer == null)
                {
                    return(num2);
                }
                if (fieldOffset > num2)
                {
                    return(0L);
                }
                length = (length > (num2 - fieldOffset)) ? ((int)(num2 - fieldOffset)) : length;
                if (length <= 0)
                {
                    return(0L);
                }
                byte[] sourceArray = id.GetBytes(sessionProxy, fieldOffset, length);
                Array.Copy(sourceArray, 0, buffer, bufferoffset, sourceArray.Length);
                return((long)sourceArray.Length);
            }
            object columnInType = this.GetColumnInType(i, SqlType.SqlVarbinary);

            if (columnInType == null)
            {
                return(0L);
            }
            if (buffer == null)
            {
                return((long)((int)((BinaryData)columnInType).Length(this._command.Connection.InnerConnection.SessionProxy)));
            }
            byte[] bytes = ((BinaryData)columnInType).GetBytes();
            if (fieldOffset > bytes.Length)
            {
                return(0L);
            }
            length = (length > bytes.Length) ? bytes.Length : length;
            if (length < 0)
            {
                length = 0;
            }
            Array.Copy(bytes, fieldOffset, buffer, (long)bufferoffset, (long)length);
            return(length);
        }
Esempio n. 2
0
        private void PerformPreExecute()
        {
            for (int i = 0; i < this._parameterValues.Length; i++)
            {
                Stream     stream;
                ClobDataId id2;
                TextReader reader;
                object     obj2 = this._parameterValues[i];
                if (obj2 == null)
                {
                    continue;
                }
                ISessionInterface sessionProxy = this._command.Connection.InnerConnection.SessionProxy;
                if (this._parameterTypes[i].TypeCode != 30)
                {
                    goto Label_010B;
                }
                byte[] buffer = obj2 as byte[];
                if (buffer == null)
                {
                    goto Label_00B1;
                }
                long       length = buffer.Length;
                BlobDataId id     = sessionProxy.CreateBlob(length);
                long       lobId  = id.GetId();
                using (MemoryStream stream2 = new MemoryStream(buffer))
                {
                    ResultLob lob = ResultLob.NewLobCreateBlobRequest(sessionProxy.GetId(), lobId, stream2, length);
                    sessionProxy.AllocateResultLob(lob, null);
                    this._resultOut.AddLobResult(lob);
                }
Label_00A2:
                this._parameterValues[i] = id;
                continue;
Label_00B1:
                stream = obj2 as Stream;
                if (stream != null)
                {
                    long      num4 = this._streamLengths[i];
                    long      num5 = sessionProxy.CreateBlob(num4).GetId();
                    ResultLob lob2 = ResultLob.NewLobCreateBlobRequest(sessionProxy.GetId(), num5, stream, num4);
                    sessionProxy.AllocateResultLob(lob2, null);
                    this._resultOut.AddLobResult(lob2);
                    goto Label_00A2;
                }
                throw new InvalidCastException();
Label_010B:
                if (this._parameterTypes[i].TypeCode != 40)
                {
                    continue;
                }
                string s = obj2 as string;
                if (s == null)
                {
                    char[] chArray = obj2 as char[];
                    if (chArray != null)
                    {
                        s = new string(chArray);
                    }
                }
                if (s == null)
                {
                    goto Label_01AD;
                }
                long num6 = s.Length;
                using (TextReader reader2 = new StringReader(s))
                {
                    id2 = sessionProxy.CreateClob(num6);
                    long      num7 = id2.GetId();
                    ResultLob lob3 = ResultLob.NewLobCreateClobRequest(sessionProxy.GetId(), num7, reader2, num6);
                    sessionProxy.AllocateResultLob(lob3, null);
                    this._resultOut.AddLobResult(lob3);
                }
Label_01A1:
                this._parameterValues[i] = id2;
                continue;
Label_01AD:
                reader = obj2 as TextReader;
                if (reader == null)
                {
                    throw new InvalidCastException();
                }
                long      num8   = this._streamLengths[i];
                long      num9   = sessionProxy.CreateClob(num8).GetId();
                ResultLob result = ResultLob.NewLobCreateClobRequest(sessionProxy.GetId(), num9, reader, num8);
                sessionProxy.AllocateResultLob(result, null);
                this._resultOut.AddLobResult(result);
                goto Label_01A1;
            }
        }