ResponseBase.cs 916 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Reflection;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace SinochemCloudClient.Models
  8. {
  9. public abstract class ResponseBase : EventArgs
  10. {
  11. public const string SuccessResponse = "200";
  12. public string code { get; set; }
  13. public string msg { get; set; }
  14. public bool IsSuccessful()
  15. {
  16. return SuccessResponse == code;
  17. }
  18. public override string ToString()
  19. {
  20. PropertyInfo[] _PropertyInfos = this.GetType().GetProperties();
  21. var sb = new StringBuilder();
  22. foreach (var info in _PropertyInfos)
  23. {
  24. var value = info.GetValue(this, null) ?? "(null)";
  25. sb.AppendLine(info.Name + ": " + value.ToString());
  26. }
  27. return sb.ToString();
  28. }
  29. }
  30. }