ExitSignalRequestInfo.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. using System.Text;
  2. namespace Renci.SshNet.Messages.Connection
  3. {
  4. /// <summary>
  5. /// Represents "exit-signal" type channel request information
  6. /// </summary>
  7. internal class ExitSignalRequestInfo : RequestInfo
  8. {
  9. /// <summary>
  10. /// Channel request name
  11. /// </summary>
  12. public const string NAME = "exit-signal";
  13. /// <summary>
  14. /// Gets the name of the request.
  15. /// </summary>
  16. /// <value>
  17. /// The name of the request.
  18. /// </value>
  19. public override string RequestName
  20. {
  21. get { return ExitSignalRequestInfo.NAME; }
  22. }
  23. /// <summary>
  24. /// Gets the name of the signal.
  25. /// </summary>
  26. /// <value>
  27. /// The name of the signal.
  28. /// </value>
  29. public string SignalName { get; private set; }
  30. /// <summary>
  31. /// Gets a value indicating whether core is dumped.
  32. /// </summary>
  33. /// <value>
  34. /// <c>true</c> if core is dumped; otherwise, <c>false</c>.
  35. /// </value>
  36. public bool CoreDumped { get; private set; }
  37. /// <summary>
  38. /// Gets the error message.
  39. /// </summary>
  40. public string ErrorMessage { get; private set; }
  41. /// <summary>
  42. /// Gets message language.
  43. /// </summary>
  44. public string Language { get; private set; }
  45. /// <summary>
  46. /// Initializes a new instance of the <see cref="ExitSignalRequestInfo"/> class.
  47. /// </summary>
  48. public ExitSignalRequestInfo()
  49. {
  50. this.WantReply = false;
  51. }
  52. /// <summary>
  53. /// Initializes a new instance of the <see cref="ExitSignalRequestInfo"/> class.
  54. /// </summary>
  55. /// <param name="signalName">Name of the signal.</param>
  56. /// <param name="coreDumped">if set to <c>true</c> then core is dumped.</param>
  57. /// <param name="errorMessage">The error message.</param>
  58. /// <param name="language">The language.</param>
  59. public ExitSignalRequestInfo(string signalName, bool coreDumped, string errorMessage, string language)
  60. : this()
  61. {
  62. this.SignalName = signalName;
  63. this.CoreDumped = coreDumped;
  64. this.ErrorMessage = errorMessage;
  65. this.Language = language;
  66. }
  67. /// <summary>
  68. /// Called when type specific data need to be loaded.
  69. /// </summary>
  70. protected override void LoadData()
  71. {
  72. base.LoadData();
  73. this.SignalName = this.ReadAsciiString();
  74. this.CoreDumped = this.ReadBoolean();
  75. this.ErrorMessage = this.ReadString();
  76. this.Language = this.ReadString();
  77. }
  78. /// <summary>
  79. /// Called when type specific data need to be saved.
  80. /// </summary>
  81. protected override void SaveData()
  82. {
  83. base.SaveData();
  84. this.WriteAscii(this.SignalName);
  85. this.Write(this.CoreDumped);
  86. this.Write(this.ErrorMessage);
  87. this.Write(this.Language);
  88. }
  89. }
  90. }