Пример #1
0
        public override object ReadObject(Hessian2Reader reader)
        {
            switch (_type)
            {
            case BasicType.Null:
                return(reader.ReadObject());

            case BasicType.Bool:
                return(reader.ReadBool());

            case BasicType.Byte:
                return((byte)reader.ReadInt());

            case BasicType.SByte:
                return((sbyte)reader.ReadInt());

            case BasicType.Short:
                return(reader.ReadShort());

            case BasicType.UShort:
                return((ushort)reader.ReadInt());

            case BasicType.Int:
                return(reader.ReadInt());

            case BasicType.UInt:
                return((uint)reader.ReadLong());

            case BasicType.Long:
                return(reader.ReadLong());

            case BasicType.Float:
                return(reader.ReadFloat());

            case BasicType.Double:
                return(reader.ReadDouble());

            case BasicType.Char:
                var str = reader.ReadString();
                return(string.IsNullOrEmpty(str) ? (char)0 : str[0]);

            case BasicType.CharArray:
                var charsString = reader.ReadString();
                return(string.IsNullOrEmpty(charsString) ? new char[0] : charsString.ToCharArray());

            case BasicType.String:
                return(reader.ReadString());

            case BasicType.Date:
                return(reader.ReadDate());

            case BasicType.ByteArray:
                return(reader.ReadBytes());

            case BasicType.Object:
                return(reader.ReadObject());

            case BasicType.BoolArray:
            case BasicType.ShortArray:
            case BasicType.IntArray:
            case BasicType.LongArray:
            case BasicType.FloatArray:
            case BasicType.StringArray:
            case BasicType.DoubleArray:
            case BasicType.SByteArray:
            case BasicType.UShortArray:
            case BasicType.UIntArray:
            case BasicType.DateArray:
            case BasicType.ObjectArray:
                return(reader.ReadObject());

            default:
                throw new ArgumentOutOfRangeException();
            }
        }