ReadObject() public abstract method

public abstract ReadObject ( System.ByteBuffer buffer ) : object
buffer System.ByteBuffer
return object
Example #1
0
        internal TAs ReadObjectInternal <T, TAs>(Stream stream)
        {
            if (!stream.CanSeek)
            {
                throw new AmqpException(AmqpErrorCode.DecodeError, "stream.CanSeek must be true.");
            }

            SerializableType type       = this.GetType(typeof(T));
            ByteBuffer       buffer     = null;
            long             position   = stream.Position;
            BufferListStream listStream = stream as BufferListStream;

            if (listStream != null)
            {
                ArraySegment <byte> segment = listStream.ReadBytes(int.MaxValue);
                buffer = new ByteBuffer(segment.Array, segment.Offset, segment.Count);
            }
            else
            {
                buffer = new ByteBuffer((int)stream.Length, false);
                int bytes = stream.Read(buffer.Buffer, 0, buffer.Capacity);
                buffer.Append(bytes);
            }

            using (buffer)
            {
                TAs value = (TAs)type.ReadObject(buffer);
                if (buffer.Length > 0)
                {
                    stream.Position = position + buffer.Offset;
                }

                return(value);
            }
        }
Example #2
0
        internal TAs ReadObjectInternal <T, TAs>(ByteBuffer buffer)
        {
            SerializableType type = this.GetType(typeof(T));

            return((TAs)type.ReadObject(buffer));
        }
Example #3
0
        public T ReadObjectInternal <T>(ByteBuffer buffer)
        {
            SerializableType type = this.GetType(typeof(T));

            return((T)type.ReadObject(buffer));
        }
        /// <summary>
        /// Reads an object from a buffer.
        /// </summary>
        /// <typeparam name="T">The expected type.</typeparam>
        /// <typeparam name="TAs">The returned type.</typeparam>
        /// <param name="buffer">The source buffer.</param>
        /// <returns>An object of TAs.</returns>
        /// <remarks>The serializer uses T to resolve decoding
        /// types and returns the decoded object as TAs.</remarks>
        public TAs ReadObjectFromBuffer <T, TAs>(ByteBuffer buffer)
        {
            SerializableType type = this.GetType(typeof(T));

            return((TAs)type.ReadObject(buffer));
        }