终端一体化运控平台
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 

42 rindas
1.2 KiB

  1. using BPA.Helper;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace BPASmartClient.DosingSystem.Service
  8. {
  9. public class FromT<T>
  10. {
  11. public APIResult<T> Result { get; set; } = new APIResult<T>();
  12. public FromT(string msg)
  13. {
  14. if (string.IsNullOrEmpty(msg))
  15. return;
  16. //Result.Content = msg.ToJson("content").FromJSON<T>();
  17. if (msg.ToJson("content").TryFromJSON(out T temp))
  18. Result.Content = temp;
  19. else
  20. {
  21. Result.Content = (T)Convert.ChangeType(msg.ToJson("content"), typeof(T));
  22. }
  23. Result.ErrorMesg = msg.ToJson("message");
  24. Result.IsSuccess = msg.ToJson("isSuccess").ToLower().FromJSON<bool>();
  25. }
  26. }
  27. public class FromT
  28. {
  29. public APIResult Result { get; set; } = new APIResult();
  30. public FromT(string msg)
  31. {
  32. if (string.IsNullOrEmpty(msg))
  33. return;
  34. Result.ErrorMesg = msg.ToJson("message");
  35. Result.IsSuccess = msg.ToJson("isSuccess").ToLower().FromJSON<bool>();
  36. }
  37. }
  38. }