using System.Linq;
using InABox.Core;
using Inflector;

namespace InABox.Rpc
{
    public class RpcQueryResult : IRpcCommandResult
    {
        public RpcQueryTable[] Tables { get; set;}
        
        public void SerializeBinary(CoreBinaryWriter writer)
        {
            writer.WriteBinaryValue(Tables);
        }

        public void DeserializeBinary(CoreBinaryReader reader)
        {
            Tables = reader.ReadBinaryValue<RpcQueryTable[]>();
        }
        
        public string FullDescription() => $"{string.Join(", ", Tables.Select(x => $"{x.Key}=({x.Table.Rows.Count} Rows / {x.Table.Columns.Count} Columns)"))}";
    }
}