示例#1
0
        internal object readObject(ComBuffer buf)
        {
            Object obj = constructor.Invoke(constructorParameters);
            int    i, j, n, len;

            for (i = 0, n = nColumns; i < n; i++)
            {
                Connection.CLIType type = (Connection.CLIType)buf.getByte();
                if (type != types[i])
                {
                    throw new CliError("Unexpected type of column: " + type
                                       + " instead of " + types[i]);
                }
                switch (types[i])
                {
                case Connection.CLIType.cli_int1:
                    columns[i].SetValue(obj, buf.getByte());
                    break;

                case Connection.CLIType.cli_int2:
                    columns[i].SetValue(obj, buf.getShort());
                    break;

                case Connection.CLIType.cli_int4:
                case Connection.CLIType.cli_autoincrement:
                    columns[i].SetValue(obj, buf.getInt());
                    break;

                case Connection.CLIType.cli_int8:
                    columns[i].SetValue(obj, buf.getLong());
                    break;

                case Connection.CLIType.cli_real4:
                    columns[i].SetValue(obj, buf.getFloat());
                    break;

                case Connection.CLIType.cli_real8:
                    columns[i].SetValue(obj, buf.getDouble());
                    break;

                case Connection.CLIType.cli_bool:
                    columns[i].SetValue(obj, buf.getByte() != 0);
                    break;

                case Connection.CLIType.cli_oid:
                {
                    int oid = buf.getInt();
                    columns[i].SetValue(obj, (oid != 0) ? new Reference(oid) : null);
                    break;
                }

                case Connection.CLIType.cli_rectangle:
                    columns[i].SetValue(obj, buf.getRectangle());
                    break;

                case Connection.CLIType.cli_asciiz:
                    columns[i].SetValue(obj, buf.getString());
                    break;

                case Connection.CLIType.cli_datetime:
                    columns[i].SetValue(obj, new DateTime(((long)buf.getInt() & 0xFFFFFFFFL) * 1000000));
                    break;

                case Connection.CLIType.cli_array_of_int1:
                {
                    len = buf.getInt();
                    byte[] arr = new byte[len];
                    for (j = 0; j < len; j++)
                    {
                        arr[j] = buf.getByte();
                    }
                    columns[i].SetValue(obj, arr);
                    break;
                }

                case Connection.CLIType.cli_array_of_int2:
                {
                    len = buf.getInt();
                    short[] arr = new short[len];
                    for (j = 0; j < len; j++)
                    {
                        arr[j] = buf.getShort();
                    }
                    columns[i].SetValue(obj, arr);
                    break;
                }

                case Connection.CLIType.cli_array_of_int4:
                {
                    len = buf.getInt();
                    int[] arr = new int[len];
                    for (j = 0; j < len; j++)
                    {
                        arr[j] = buf.getInt();
                    }
                    columns[i].SetValue(obj, arr);
                    break;
                }

                case Connection.CLIType.cli_array_of_int8:
                {
                    len = buf.getInt();
                    long[] arr = new long[len];
                    for (j = 0; j < len; j++)
                    {
                        arr[j] = buf.getLong();
                    }
                    columns[i].SetValue(obj, arr);
                    break;
                }

                case Connection.CLIType.cli_array_of_real4:
                {
                    len = buf.getInt();
                    float[] arr = new float[len];
                    for (j = 0; j < len; j++)
                    {
                        arr[j] = buf.getFloat();
                    }
                    columns[i].SetValue(obj, arr);
                    break;
                }

                case Connection.CLIType.cli_array_of_real8:
                {
                    len = buf.getInt();
                    double[] arr = new double[len];
                    for (j = 0; j < len; j++)
                    {
                        arr[j] = buf.getDouble();
                    }
                    columns[i].SetValue(obj, arr);
                    break;
                }

                case Connection.CLIType.cli_array_of_bool:
                {
                    len = buf.getInt();
                    bool[] arr = new bool[len];
                    for (j = 0; j < len; j++)
                    {
                        arr[j] = buf.getByte() != 0;
                    }
                    columns[i].SetValue(obj, arr);
                    break;
                }

                case Connection.CLIType.cli_array_of_oid:
                {
                    len = buf.getInt();
                    Reference[] arr = new Reference[len];
                    for (j = 0; j < len; j++)
                    {
                        int oid = buf.getInt();
                        arr[j] = oid != 0 ? new Reference(oid) : null;
                    }
                    columns[i].SetValue(obj, arr);
                    break;
                }

                case Connection.CLIType.cli_array_of_string:
                {
                    len = buf.getInt();
                    string[] arr = new string[len];
                    for (j = 0; j < len; j++)
                    {
                        arr[j] = buf.getAsciiz();
                    }
                    columns[i].SetValue(obj, arr);
                    break;
                }

                default:
                    throw new CliError("Unsupported type " + types[i]);
                }
            }
            return(obj);
        }
示例#2
0
 internal Parameter(string name)
 {
     this.name = name;
     type = Connection.CLIType.cli_undefined;
 }
示例#3
0
 internal Parameter(string name)
 {
     this.name = name;
     type      = Connection.CLIType.cli_undefined;
 }