using System.Text;
namespace Renci.SshNet.Messages.Connection
{
    /// 
    /// Represents "exit-signal" type channel request information
    /// 
    internal class ExitSignalRequestInfo : RequestInfo
    {
        /// 
        /// Channel request name
        /// 
        public const string NAME = "exit-signal";
        /// 
        /// Gets the name of the request.
        /// 
        /// 
        /// The name of the request.
        /// 
        public override string RequestName
        {
            get { return ExitSignalRequestInfo.NAME; }
        }
        /// 
        /// Gets the name of the signal.
        /// 
        /// 
        /// The name of the signal.
        /// 
        public string SignalName { get; private set; }
        /// 
        /// Gets a value indicating whether core is dumped.
        /// 
        /// 
        ///   true if core is dumped; otherwise, false.
        /// 
        public bool CoreDumped { get; private set; }
        /// 
        /// Gets the error message.
        /// 
        public string ErrorMessage { get; private set; }
        /// 
        /// Gets message language.
        /// 
        public string Language { get; private set; }
        /// 
        /// Initializes a new instance of the  class.
        /// 
        public ExitSignalRequestInfo()
        {
            this.WantReply = false;
        }
        /// 
        /// Initializes a new instance of the  class.
        /// 
        /// Name of the signal.
        /// if set to true then core is dumped.
        /// The error message.
        /// The language.
        public ExitSignalRequestInfo(string signalName, bool coreDumped, string errorMessage, string language)
            : this()
        {
            this.SignalName = signalName;
            this.CoreDumped = coreDumped;
            this.ErrorMessage = errorMessage;
            this.Language = language;
        }
        /// 
        /// Called when type specific data need to be loaded.
        /// 
        protected override void LoadData()
        {
            base.LoadData();
            this.SignalName = this.ReadAsciiString();
            this.CoreDumped = this.ReadBoolean();
            this.ErrorMessage = this.ReadString();
            this.Language = this.ReadString();
        }
        /// 
        /// Called when type specific data need to be saved.
        /// 
        protected override void SaveData()
        {
            base.SaveData();
            this.WriteAscii(this.SignalName);
            this.Write(this.CoreDumped);
            this.Write(this.ErrorMessage);
            this.Write(this.Language);
        }
    }
}