Exemplo n.º 1
0
        public T[] ReadArray <T>()
        {
            if (!IsValid)
            {
                throw new PrimitiveValueWrapperException("Trying to access an invalid PrimitiveValueWrapper.");
            }

            return(BaseSerializers.ReadArray <T>(ReadBytes()));
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Reads an ulong from the Underlaying Stream
        /// </summary>
        /// <returns>Deserialized ulong</returns>
        public ulong ReadULong()
        {
            if (!IsValid)
            {
                throw new PrimitiveValueWrapperException("Trying to access an invalid PrimitiveValueWrapper.");
            }

            byte[] buf = new byte[sizeof(ulong)];
            stream.Read(buf, 0, buf.Length);
            return(BaseSerializers.ReadULong(buf));
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Writes a double to the Stream
        /// </summary>
        /// <param name="value">Value to Write</param>
        /// <returns>Bytes Written</returns>
        public int Write(double value)
        {
            if (!IsValid)
            {
                throw new PrimitiveValueWrapperException("Trying to access an invalid PrimitiveValueWrapper.");
            }

            byte[] buf = BaseSerializers.Write(value);
            packetCache.AddRange(buf);
            return(buf.Length);
        }
Exemplo n.º 4
0
        /// <summary>
        ///     Reads a string from the Underlaying Stream
        /// </summary>
        /// <returns>Deserialized string</returns>
        public string ReadString()
        {
            if (!IsValid)
            {
                throw new PrimitiveValueWrapperException("Trying to access an invalid PrimitiveValueWrapper.");
            }

            int len = ReadInt();

            byte[] buf = new byte[len];
            stream.Read(buf, 0, buf.Length);
            return(BaseSerializers.ReadString(buf));
        }
Exemplo n.º 5
0
 public void WriteArray <T>(T[] input)
 {
     Write(BaseSerializers.WriteArray(input));
 }
Exemplo n.º 6
0
 /// <summary>
 ///     Reads a double from the Underlaying Stream
 /// </summary>
 /// <returns>Deserialized double</returns>
 public double ReadDouble()
 {
     byte[] buf = new byte[sizeof(double)];
     stream.Read(buf, 0, buf.Length);
     return(BaseSerializers.ReadDouble(buf));
 }