ViewResult.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace CB.TVUCenter
  5. {
  6. /// <summary>
  7. /// 输出结果
  8. /// </summary>
  9. /// <typeparam name="T"></typeparam>
  10. public class ViewResult<T>
  11. {
  12. public ViewResult()
  13. {
  14. }
  15. public int Code { get; set; }
  16. public string Message { get; set; }
  17. public T Entity { get; set; }
  18. public override string ToString()
  19. {
  20. var sp = new StringBuilder(2000);
  21. sp.Append("<?xml version=\"1.0\" encoding=\"utf-8\" ?>");
  22. sp.Append("<Channel>");
  23. sp.AppendFormat("<Code>{0}</Code>", this.Code);
  24. if (0 != this.Code)
  25. {
  26. sp.AppendFormat("<Result>{0}</Result>", this.Message);
  27. }
  28. else
  29. {
  30. sp.AppendFormat("<Result>{0}</Result>", null == Entity ? "" : this.Entity.ToString());
  31. }
  32. sp.Append("</Channel>");
  33. return sp.ToString();
  34. }
  35. }
  36. }