Esempio n. 1
0
        private void SetParameter(int i, UtlParameter param)
        {
            object o = param.Value;

            if ((o == null) || (o == DBNull.Value))
            {
                this._parameterValues[i] = null;
                return;
            }
            ISessionInterface sessionProxy = this._command.Connection.InnerConnection.SessionProxy;
            SqlType           type         = this._parameterTypes[i];
            int typeCode = type.TypeCode;

            if (typeCode <= 30)
            {
                if (typeCode > 0x15)
                {
                    switch (typeCode)
                    {
                    case 0x19:
                    case 30:
                        goto Label_028B;
                    }
                    this._parameterValues[i] = o;
                    return;
                }
                switch (typeCode)
                {
                case 0x15:
                {
                    DataTable dataTable = o as DataTable;
                    if (dataTable != null)
                    {
                        dataTable.TableName = this._parameterNames[i];
                        if (!((TableType)this._parameterTypes[i]).IsCompatible(dataTable))
                        {
                            goto Label_0379;
                        }
                        goto Label_03AF;
                    }
                    DbDataReader reader = o as DbDataReader;
                    if (reader == null)
                    {
                        goto Label_03AF;
                    }
                    dataTable = new DataTable(this._parameterNames[i]);
                    UtlMetaData.PopulateDataTable(dataTable, reader);
                    if (((TableType)this._parameterTypes[i]).IsCompatible(dataTable))
                    {
                        o = dataTable;
                        goto Label_03AF;
                    }
                    goto Label_0379;
                }
                }
            }
            else
            {
                if (typeCode <= 0x3d)
                {
                    if (typeCode == 40)
                    {
                        this._parameterValues[i] = o;
                        return;
                    }
                    if ((typeCode - 60) > 1)
                    {
                        goto Label_028B;
                    }
                    byte[] data = o as byte[];
                    if (data != null)
                    {
                        o = new BinaryData(data, !this._command.Connection.IsNetConnection);
                    }
                    else
                    {
                        try
                        {
                            if (o is string)
                            {
                                o = type.ConvertToDefaultType(sessionProxy, o);
                                goto Label_03AF;
                            }
                        }
                        catch (CoreException exception1)
                        {
                            UtlException.ThrowError(exception1);
                        }
                        UtlException.ThrowError(Error.GetError(0x15bd));
                    }
                    goto Label_03AF;
                }
                switch (typeCode)
                {
                case 0x5b:
                case 0x5c:
                case 0x5d:
                case 0x5e:
                case 0x5f:
                    try
                    {
                        if (((param.UtlType == UtlType.Null) && (o is string)) || (((param.UtlType == UtlType.VarChar) || (param.UtlType == UtlType.Char)) || (param.UtlType == UtlType.VarCharIngnoreCase)))
                        {
                            o = type.ConvertToType(sessionProxy, o, SqlType.SqlVarchar);
                        }
                        else
                        {
                            o = type.ConvertCSharpToSQL(sessionProxy, o);
                        }
                    }
                    catch (CoreException exception2)
                    {
                        UtlException.ThrowError(exception2);
                    }
                    goto Label_03AF;

                case 0x65:
                case 0x66:
                case 0x6b:
                {
                    MonthSpan span = (MonthSpan)o;
                    o = new IntervalMonthData((long)span.TotalMonths);
                    goto Label_03AF;
                }

                case 0x67:
                case 0x68:
                case 0x69:
                case 0x6a:
                case 0x6c:
                case 0x6d:
                case 110:
                case 0x6f:
                case 0x70:
                case 0x71:
                {
                    TimeSpan span2        = (TimeSpan)o;
                    long     totalSeconds = (long)span2.TotalSeconds;
                    int      nanos        = (int)((span2.TotalSeconds - totalSeconds) * 1000000000.0);
                    o = new IntervalSecondData(totalSeconds, nanos);
                    goto Label_03AF;
                }

                case 0x457:
                    try
                    {
                        if (o.GetType().IsSerializable)
                        {
                            o = new OtherData(o);
                            goto Label_03AF;
                        }
                    }
                    catch (CoreException exception3)
                    {
                        UtlException.ThrowError(exception3);
                    }
                    UtlException.ThrowError(Error.GetError(0x15bd));
                    goto Label_03AF;
                }
            }
            Label_028B :;
            try
            {
                if (((param.UtlType == UtlType.Null) && (o is string)) || (((param.UtlType == UtlType.VarChar) || (param.UtlType == UtlType.Char)) || (param.UtlType == UtlType.VarCharIngnoreCase)))
                {
                    o = type.ConvertToType(sessionProxy, o, SqlType.SqlVarchar);
                }
                else if (param.UtlType == UtlType.Null)
                {
                    o = type.ConvertToDefaultType(sessionProxy, o);
                }
                else
                {
                    SqlType type2 = this.UtlType2SqlType(param.UtlType);
                    o = type.ConvertToType(sessionProxy, o, type2);
                }
            }
            catch (CoreException exception4)
            {
                UtlException.ThrowError(exception4);
            }
            goto Label_03AF;
            Label_0379 :;
            try
            {
                if (param.UtlType == UtlType.Null)
                {
                    o = type.ConvertToDefaultType(sessionProxy, o);
                }
                else
                {
                    SqlType type3 = this.UtlType2SqlType(param.UtlType);
                    o = type.ConvertToType(sessionProxy, o, type3);
                }
            }
            catch (CoreException exception5)
            {
                UtlException.ThrowError(exception5);
            }
Label_03AF:
            this._parameterValues[i] = o;
        }