ResultBase.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* ==============================================================================
  2. * 功能描述:
  3. * 创 建 者:Garrett
  4. * 创建日期:2019/5/31 16:24:04
  5. * ==============================================================================*/
  6. using System;
  7. using MBIRevitBase;
  8. namespace ServiceRevitLib.Mode
  9. {
  10. /// <summary>
  11. /// CheckResultBase
  12. /// </summary>
  13. public class ResultBase
  14. {
  15. public ResultBase()
  16. {
  17. Result = ResultState.Success;
  18. }
  19. /// <summary>
  20. /// 异常结果
  21. /// </summary>
  22. /// <param name="msg"></param>
  23. /// <returns></returns>
  24. public static ResultBase Exception(string msg)
  25. {
  26. return new ResultBase(){Result = ResultState.Failure,ResultMsg = msg};
  27. }
  28. /// <summary>
  29. /// 成功或失败结果描述
  30. /// </summary>
  31. public string ResultMsg { get; set; }
  32. /// <summary>
  33. /// 结果
  34. /// </summary>
  35. public ResultState Result { get; set; }
  36. public static implicit operator ResultBase(BResult result)
  37. {
  38. return new ResultBase()
  39. {
  40. ResultMsg = result.Message,
  41. Result = (ResultState)(Convert.ToInt32(result.IsSuccessed))
  42. };
  43. }
  44. }
  45. }