EnvironmentVariableRequestInfo.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. namespace Renci.SshNet.Messages.Connection
  2. {
  3. /// <summary>
  4. /// Represents "env" type channel request information
  5. /// </summary>
  6. internal class EnvironmentVariableRequestInfo : RequestInfo
  7. {
  8. /// <summary>
  9. /// Channel request name
  10. /// </summary>
  11. public const string NAME = "env";
  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 or sets the name of the variable.
  24. /// </summary>
  25. /// <value>
  26. /// The name of the variable.
  27. /// </value>
  28. public string VariableName { get; set; }
  29. /// <summary>
  30. /// Gets or sets the variable value.
  31. /// </summary>
  32. /// <value>
  33. /// The variable value.
  34. /// </value>
  35. public string VariableValue { get; set; }
  36. /// <summary>
  37. /// Initializes a new instance of the <see cref="EnvironmentVariableRequestInfo"/> class.
  38. /// </summary>
  39. public EnvironmentVariableRequestInfo()
  40. {
  41. this.WantReply = true;
  42. }
  43. /// <summary>
  44. /// Initializes a new instance of the <see cref="EnvironmentVariableRequestInfo"/> class.
  45. /// </summary>
  46. /// <param name="variableName">Name of the variable.</param>
  47. /// <param name="variableValue">The variable value.</param>
  48. public EnvironmentVariableRequestInfo(string variableName, string variableValue)
  49. : this()
  50. {
  51. this.VariableName = variableName;
  52. this.VariableValue = variableValue;
  53. }
  54. /// <summary>
  55. /// Called when type specific data need to be loaded.
  56. /// </summary>
  57. protected override void LoadData()
  58. {
  59. base.LoadData();
  60. this.VariableName = this.ReadString();
  61. this.VariableValue = this.ReadString();
  62. }
  63. /// <summary>
  64. /// Called when type specific data need to be saved.
  65. /// </summary>
  66. protected override void SaveData()
  67. {
  68. base.SaveData();
  69. this.Write(this.VariableName);
  70. this.Write(this.VariableValue);
  71. }
  72. }
  73. }