/// <summary>
        /// Deserializa o valor.
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        private object Deserialize(Serialization.IO.CompactReader reader, PrimitiveTypes type)
        {
            switch (type)
            {
            case PrimitiveTypes.Null:
                return(null);

            case PrimitiveTypes.Boolean:
                return(reader.ReadBoolean());

            case PrimitiveTypes.Byte:
                return(reader.ReadByte());

            case PrimitiveTypes.Bytes:
                var length = reader.ReadInt32();
                return(reader.ReadBytes(length));

            case PrimitiveTypes.Char:
                return(reader.ReadChar());

            case PrimitiveTypes.DateTime:
                return(reader.ReadDateTime());

            case PrimitiveTypes.DateTimeOffset:
                return(new DateTimeOffset(reader.ReadInt64(), new TimeSpan(reader.ReadInt64())));

            case PrimitiveTypes.Decimal:
                return(reader.ReadDecimal());

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

            case PrimitiveTypes.Int16:
                return(reader.ReadInt16());

            case PrimitiveTypes.Int32:
                return(reader.ReadInt32());

            case PrimitiveTypes.Int64:
                return(reader.ReadInt64());

            case PrimitiveTypes.Single:
                return(reader.ReadSingle());

            case PrimitiveTypes.String:
                return(reader.ReadString());
            }
            throw new InvalidOperationException("Invalid PrimitiveType");
        }