You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

44 lines
1.2 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. namespace SUISS.Cloud
  4. {
  5. public class ReceivedMessage : IReceivedMessage
  6. {
  7. public string MessageUuid { get; private set; }
  8. public string FromAccountUuid { get; private set; }
  9. public string FromInstallUuid { get; private set; }
  10. public IDictionary<string, object> Data { get; private set; }
  11. public string MessageType { get; private set; }
  12. public DateTime CreatedAt { get; private set; }
  13. public int Version { get; private set; }
  14. public static ReceivedMessage FromJson(object json)
  15. {
  16. if (json is Dictionary<string, object>)
  17. {
  18. Dictionary<string, object> dictionary = (Dictionary<string, object>)json;
  19. if (dictionary.ContainsKey("messageUuid"))
  20. {
  21. return new ReceivedMessage
  22. {
  23. MessageUuid = (string)dictionary["messageUuid"],
  24. MessageType = (string)dictionary["messageType"],
  25. Data = (IDictionary<string, object>)dictionary["data"],
  26. FromAccountUuid = (string)dictionary["fromAccountUuid"],
  27. FromInstallUuid = (string)dictionary["fromInstallUuid"],
  28. Version = Convert.ToInt32((double)dictionary["version"])
  29. };
  30. }
  31. }
  32. return null;
  33. }
  34. }
  35. }