using System.Linq;
using InABox.Core;

namespace InABox.Rpc
{
    public class RpcQueryParameters : IRpcCommandParameters
    {
        public string CommandName => "Query";

        public RpcQueryDefinition[] Queries { get; set; }

        public void SerializeBinary(CoreBinaryWriter writer)
        {
            writer.WriteBinaryValue(Queries);
        }

        public void DeserializeBinary(CoreBinaryReader reader)
        {
            Queries = reader.ReadBinaryValue<RpcQueryDefinition[]>();
        }

        public string FullDescription() => $"{string.Join(", ", Queries.Select(x=>$"{x.Key}={x.FullDescription()}"))}";

        public string ShortDescription() => $"Query";
    }
}