PageRenderTime 37ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 1ms

/Senparc.Weixin.MP/Senparc.Weixin.MP/Helpers/MsgTypeHelper.cs

https://github.com/mjhuangzk/WeiXinMPSDK
C# | 51 lines | 31 code | 4 blank | 16 comment | 0 complexity | ee18b2547d9b8da97ca9e11f1958df61 MD5 | raw file
Possible License(s): BSD-2-Clause, BSD-3-Clause
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Xml.Linq;
  6. namespace Senparc.Weixin.MP.Helpers
  7. {
  8. public static class MsgTypeHelper
  9. {
  10. #region RequestMsgType
  11. /// <summary>
  12. /// 根据xml信息,返回RequestMsgType
  13. /// </summary>
  14. /// <returns></returns>
  15. public static RequestMsgType GetRequestMsgType(XDocument doc)
  16. {
  17. return GetRequestMsgType(doc.Root.Element("MsgType").Value);
  18. }
  19. /// <summary>
  20. /// 根据xml信息,返回RequestMsgType
  21. /// </summary>
  22. /// <returns></returns>
  23. public static RequestMsgType GetRequestMsgType(string str)
  24. {
  25. return (RequestMsgType)Enum.Parse(typeof(RequestMsgType), str, true);
  26. }
  27. #endregion
  28. #region ResponseMsgType
  29. /// <summary>
  30. /// 根据xml信息,返回ResponseMsgType
  31. /// </summary>
  32. /// <returns></returns>
  33. public static ResponseMsgType GetResponseMsgType(XDocument doc)
  34. {
  35. return GetResponseMsgType(doc.Root.Element("MsgType").Value);
  36. }
  37. /// <summary>
  38. /// 根据xml信息,返回ResponseMsgType
  39. /// </summary>
  40. /// <returns></returns>
  41. public static ResponseMsgType GetResponseMsgType(string str)
  42. {
  43. return (ResponseMsgType)Enum.Parse(typeof(ResponseMsgType), str, true);
  44. }
  45. #endregion
  46. }
  47. }