using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using log4net;
using Concilium.Helpers;
using System.Net;
using System.Diagnostics;

namespace Concilium.Bot
{
    public class InvalidCommandParametersException : Exception
    {
        public InvalidCommandParametersException(string _sCommand, int minParameters, int? maxParameters = null)
            : base()
        {
            m_sCommand = _sCommand;

            Debug.Assert(minParameters >= 0,
                "minParameters must be at least zero.");
            Debug.Assert(maxParameters == null || maxParameters >= minParameters,
                "maxParameters must be at least minParameters.");

            this.MinParameters = minParameters;
            this.MaxParameters = maxParameters ?? minParameters;
        }

        public int MinParameters
        {
            get;
            private set;
        }

        public int MaxParameters
        {
            get;
            private set;
        }

        public override string Message
        {
            get
            {
                if (this.MinParameters == 0 && this.MaxParameters == 0)
                    return string.Format("Command {0} takes no parameters", m_sCommand);
                else if (this.MinParameters == this.MaxParameters)
                    return string.Format("Command {0} takes {1} parameters", m_sCommand, this.MinParameters);
                else
                    return string.Format("Command {0} takes {1} to {2} parameters", m_sCommand, this.MinParameters, this.MaxParameters);
            }
        }

        private string m_sCommand;
    }
}
