RequestInfo.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace SuperSocket.SocketBase.Protocol
  6. {
  7. /// <summary>
  8. /// RequestInfo basic class
  9. /// </summary>
  10. /// <typeparam name="TRequestBody">The type of the request body.</typeparam>
  11. public class RequestInfo<TRequestBody> : IRequestInfo<TRequestBody>
  12. {
  13. /// <summary>
  14. /// Initializes a new instance of the <see cref="RequestInfo&lt;TRequestBody&gt;"/> class.
  15. /// </summary>
  16. protected RequestInfo()
  17. {
  18. }
  19. /// <summary>
  20. /// Initializes a new instance of the <see cref="RequestInfo&lt;TRequestBody&gt;"/> class.
  21. /// </summary>
  22. /// <param name="key">The key.</param>
  23. /// <param name="body">The body.</param>
  24. public RequestInfo(string key, TRequestBody body)
  25. {
  26. Initialize(key, body);
  27. }
  28. /// <summary>
  29. /// Initializes the specified key.
  30. /// </summary>
  31. /// <param name="key">The key.</param>
  32. /// <param name="body">The body.</param>
  33. protected void Initialize(string key, TRequestBody body)
  34. {
  35. Key = key;
  36. Body = body;
  37. }
  38. /// <summary>
  39. /// Gets the key of this request.
  40. /// </summary>
  41. public string Key { get; private set; }
  42. /// <summary>
  43. /// Gets the body.
  44. /// </summary>
  45. public TRequestBody Body { get; private set; }
  46. }
  47. /// <summary>
  48. /// RequestInfo with header
  49. /// </summary>
  50. /// <typeparam name="TRequestHeader">The type of the request header.</typeparam>
  51. /// <typeparam name="TRequestBody">The type of the request body.</typeparam>
  52. public class RequestInfo<TRequestHeader, TRequestBody> : RequestInfo<TRequestBody>, IRequestInfo<TRequestHeader, TRequestBody>
  53. {
  54. /// <summary>
  55. /// Initializes a new instance of the <see cref="RequestInfo&lt;TRequestHeader, TRequestBody&gt;"/> class.
  56. /// </summary>
  57. public RequestInfo()
  58. {
  59. }
  60. /// <summary>
  61. /// Initializes a new instance of the <see cref="RequestInfo&lt;TRequestHeader, TRequestBody&gt;"/> class.
  62. /// </summary>
  63. /// <param name="key">The key.</param>
  64. /// <param name="header">The header.</param>
  65. /// <param name="body">The body.</param>
  66. public RequestInfo(string key, TRequestHeader header, TRequestBody body)
  67. : base(key, body)
  68. {
  69. Header = header;
  70. }
  71. /// <summary>
  72. /// Initializes the specified key.
  73. /// </summary>
  74. /// <param name="key">The key.</param>
  75. /// <param name="header">The header.</param>
  76. /// <param name="body">The body.</param>
  77. public void Initialize(string key, TRequestHeader header, TRequestBody body)
  78. {
  79. base.Initialize(key, body);
  80. Header = header;
  81. }
  82. /// <summary>
  83. /// Gets the header.
  84. /// </summary>
  85. public TRequestHeader Header { get; private set; }
  86. }
  87. }