ExitStatusRequestInfo.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. namespace Renci.SshNet.Messages.Connection
  2. {
  3. /// <summary>
  4. /// Represents "exit-status" type channel request information
  5. /// </summary>
  6. internal class ExitStatusRequestInfo : RequestInfo
  7. {
  8. /// <summary>
  9. /// Channel request name.
  10. /// </summary>
  11. public const string Name = "exit-status";
  12. /// <summary>
  13. /// Gets the name of the request.
  14. /// </summary>
  15. /// <value>
  16. /// The name of the request.
  17. /// </value>
  18. public override string RequestName
  19. {
  20. get { return Name; }
  21. }
  22. /// <summary>
  23. /// Gets the exit status number.
  24. /// </summary>
  25. public uint ExitStatus { get; private set; }
  26. protected override int BufferCapacity
  27. {
  28. get
  29. {
  30. var capacity = base.BufferCapacity;
  31. capacity += 4; // ExitStatus
  32. return capacity;
  33. }
  34. }
  35. /// <summary>
  36. /// Initializes a new instance of the <see cref="ExitStatusRequestInfo"/> class.
  37. /// </summary>
  38. public ExitStatusRequestInfo()
  39. {
  40. WantReply = false;
  41. }
  42. /// <summary>
  43. /// Initializes a new instance of the <see cref="ExitStatusRequestInfo"/> class.
  44. /// </summary>
  45. /// <param name="exitStatus">The exit status number.</param>
  46. public ExitStatusRequestInfo(uint exitStatus)
  47. : this()
  48. {
  49. ExitStatus = exitStatus;
  50. }
  51. /// <summary>
  52. /// Called when type specific data need to be loaded.
  53. /// </summary>
  54. protected override void LoadData()
  55. {
  56. base.LoadData();
  57. ExitStatus = ReadUInt32();
  58. }
  59. /// <summary>
  60. /// Called when type specific data need to be saved.
  61. /// </summary>
  62. protected override void SaveData()
  63. {
  64. base.SaveData();
  65. Write(ExitStatus);
  66. }
  67. }
  68. }