using System.Text;
namespace Renci.SshNet.Messages.Connection
{
    /// 
    /// Represents "exec" type channel request information
    /// 
    internal class ExecRequestInfo : RequestInfo
    {
        /// 
        /// Channel request name
        /// 
        public const string NAME = "exec";
        /// 
        /// Gets the name of the request.
        /// 
        /// 
        /// The name of the request.
        /// 
        public override string RequestName
        {
            get { return NAME; }
        }
        /// 
        /// Gets command to execute.
        /// 
        /// 
        /// The command.
        /// 
        public string Command { get; private set; }
        /// 
        /// Gets the encoding.
        /// 
        /// 
        /// The encoding.
        /// 
        public Encoding Encoding { get; private set; }
        /// 
        /// Initializes a new instance of the  class.
        /// 
        public ExecRequestInfo()
        {
            this.WantReply = true;
        }
        /// 
        /// Initializes a new instance of the  class.
        /// 
        /// The command.
        /// The character encoding to use.
        ///  or  is null.
        public ExecRequestInfo(string command, Encoding encoding)
            : this()
        {
            if (command == null)
                throw new System.ArgumentNullException("command");
            if (encoding == null)
                throw new System.ArgumentNullException("encoding");
            this.Command = command;
            this.Encoding = encoding;
        }
        /// 
        /// Called when type specific data need to be loaded.
        /// 
        protected override void LoadData()
        {
            base.LoadData();
            this.Command = this.ReadString();
        }
        /// 
        /// Called when type specific data need to be saved.
        /// 
        protected override void SaveData()
        {
            base.SaveData();
            this.Write(this.Command, this.Encoding);
        }
    }
}