RequestData.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace HPSocketCS.Extended
  6. {
  7. /// <summary>
  8. ///请求数据处理类
  9. /// </summary>
  10. [Serializable]
  11. public class RequestData
  12. {
  13. public RequestData() {
  14. }
  15. public RequestData(int rCommand)
  16. {
  17. this._RequestCommand = rCommand;
  18. }
  19. private Int32 _RequestCommand;
  20. /// <summary>
  21. /// 请求命令
  22. /// </summary>
  23. public Int32 RequestCommand
  24. {
  25. get { return _RequestCommand; }
  26. set { _RequestCommand = value; }
  27. }
  28. byte[] _AttachedData = null;
  29. /// <summary>
  30. /// 附加数据
  31. /// </summary>
  32. public byte[] AttachedData
  33. {
  34. get { return _AttachedData; }
  35. set { _AttachedData = value; }
  36. }
  37. string _AttachedMessage = "";
  38. /// <summary>
  39. /// 附加消息
  40. /// </summary>
  41. public string AttachedMessage
  42. {
  43. get { return _AttachedMessage; }
  44. set { _AttachedMessage = value; }
  45. }
  46. /// <summary>
  47. /// 将附加数据字节娄组转为对象
  48. /// </summary>
  49. /// <typeparam name="T"></typeparam>
  50. /// <returns></returns>
  51. public T AttachedDataToObject<T>()
  52. {
  53. try
  54. {
  55. return (T)HPSocketCS.Extended.DataSetSerializerDeserialize.ObjectDeserialize(this._AttachedData);
  56. }
  57. catch
  58. {
  59. return default(T);
  60. }
  61. }
  62. }
  63. }