IgnoreMessage.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using System;
  2. namespace Renci.SshNet.Messages.Transport
  3. {
  4. /// <summary>
  5. /// Represents SSH_MSG_IGNORE message.
  6. /// </summary>
  7. [Message("SSH_MSG_IGNORE", MessageNumber)]
  8. public class IgnoreMessage : Message
  9. {
  10. internal const byte MessageNumber = 2;
  11. /// <summary>
  12. /// Gets ignore message data if any.
  13. /// </summary>
  14. public byte[] Data { get; private set; }
  15. /// <summary>
  16. /// Initializes a new instance of the <see cref="IgnoreMessage"/> class
  17. /// </summary>
  18. public IgnoreMessage()
  19. {
  20. Data = new byte[0];
  21. }
  22. #if TUNING
  23. /// <summary>
  24. /// Gets the size of the message in bytes.
  25. /// </summary>
  26. /// <value>
  27. /// The size of the messages in bytes.
  28. /// </value>
  29. protected override int BufferCapacity
  30. {
  31. get
  32. {
  33. var capacity = base.BufferCapacity;
  34. capacity += 4; // Data length
  35. capacity += Data.Length; // Data
  36. return capacity;
  37. }
  38. }
  39. #endif
  40. /// <summary>
  41. /// Initializes a new instance of the <see cref="IgnoreMessage"/> class.
  42. /// </summary>
  43. /// <param name="data">The data.</param>
  44. public IgnoreMessage(byte[] data)
  45. {
  46. if (data == null)
  47. throw new ArgumentNullException("data");
  48. Data = data;
  49. }
  50. /// <summary>
  51. /// Called when type specific data need to be loaded.
  52. /// </summary>
  53. protected override void LoadData()
  54. {
  55. #if TUNING
  56. Data = ReadBinary();
  57. #else
  58. Data = ReadBinaryString();
  59. #endif
  60. }
  61. /// <summary>
  62. /// Called when type specific data need to be saved.
  63. /// </summary>
  64. protected override void SaveData()
  65. {
  66. WriteBinaryString(Data);
  67. }
  68. }
  69. }