ExecRequestInfo.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using System.Text;
  2. namespace Renci.SshNet.Messages.Connection
  3. {
  4. /// <summary>
  5. /// Represents "exec" type channel request information
  6. /// </summary>
  7. internal class ExecRequestInfo : RequestInfo
  8. {
  9. /// <summary>
  10. /// Channel request name
  11. /// </summary>
  12. public const string NAME = "exec";
  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 ExecRequestInfo.NAME; }
  22. }
  23. /// <summary>
  24. /// Gets command to execute.
  25. /// </summary>
  26. public string Command { get; private set; }
  27. /// <summary>
  28. /// Initializes a new instance of the <see cref="ExecRequestInfo"/> class.
  29. /// </summary>
  30. public ExecRequestInfo()
  31. {
  32. this.WantReply = true;
  33. }
  34. /// <summary>
  35. /// Initializes a new instance of the <see cref="ExecRequestInfo"/> class.
  36. /// </summary>
  37. /// <param name="command">The command.</param>
  38. /// <exception cref="ArgumentNullException"><paramref name="command"/> is null.</exception>
  39. public ExecRequestInfo(string command)
  40. : this()
  41. {
  42. if (command == null)
  43. throw new System.ArgumentNullException("command");
  44. this.Command = command;
  45. }
  46. /// <summary>
  47. /// Called when type specific data need to be loaded.
  48. /// </summary>
  49. protected override void LoadData()
  50. {
  51. base.LoadData();
  52. this.Command = this.ReadString();
  53. }
  54. /// <summary>
  55. /// Called when type specific data need to be saved.
  56. /// </summary>
  57. protected override void SaveData()
  58. {
  59. base.SaveData();
  60. this.Write(this.Command);
  61. }
  62. }
  63. }