Esempio n. 1
0
        public override object ReadValue(HessianReader reader, HessianContext context, Type objectType, byte initialOctet)
        {
            using (var stream = new MemoryStream())
            {
                while (initialOctet == Constants.BC_BINARY_CHUNK)
                {
                    int len = reader.ReadInt16();
                    FillBuffer(reader, stream, len);
                    initialOctet = reader.ReadByte();
                }

                if (initialOctet == Constants.BC_BINARY)
                {
                    int len = reader.ReadInt16();
                    FillBuffer(reader, stream, len);
                }
                else if (Constants.BC_BINARY_DIRECT <= initialOctet && initialOctet <= Constants.BC_BINARY_DIRECT + Constants.BINARY_DIRECT_MAX)
                {
                    FillBuffer(reader, stream, initialOctet - Constants.BC_BINARY_DIRECT);
                }
                else
                {
                    throw Exceptions.UnExpectedInitialOctet(this, initialOctet);
                }
                return(stream.ToArray());
            }
        }
Esempio n. 2
0
 public override object ReadValue(HessianReader reader, HessianContext context, Type objectType, byte initialOctet)
 {
     if (initialOctet == Constants.BC_DOUBLE_ZERO)
     {
         return(0d);
     }
     else if (initialOctet == Constants.BC_DOUBLE_ONE)
     {
         return(1d);
     }
     else if (initialOctet == Constants.BC_DOUBLE_BYTE)
     {
         return((double)reader.ReadSByte());
     }
     else if (initialOctet == Constants.BC_DOUBLE_SHORT)
     {
         return((double)reader.ReadInt16());
     }
     else if (initialOctet == Constants.BC_DOUBLE_MILL)
     {
         return(reader.ReadInt32() / 1000.0d);
     }
     else if (initialOctet == Constants.BC_DOUBLE)
     {
         return(reader.ReadDouble());
     }
     else
     {
         throw Exceptions.UnExpectedInitialOctet(this, initialOctet);
     }
 }