/*------------------------------------------------------------------------- * 功能描述:BResult * 作者:xulisong * 创建时间: 2019/7/29 17:54:09 * 版本号:v1.0 * -------------------------------------------------------------------------*/ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace MBIRevitBase { /// /// bool类型结果 /// public class BResult { public BResult(bool isSuccessed) { IsSuccessed = isSuccessed; } public BResult(bool isSuccessed, string message) : this(isSuccessed) { Message = message; } public bool IsSuccessed { get; private set; } public string Id { get; set; } public string Message { get; set; } /// /// tag /// public object Tag { get; set; } public static implicit operator bool(BResult result) { return result.IsSuccessed; } public static implicit operator BResult(bool d) { return new BResult(d); } public static implicit operator BResult(string errorMessage) { //有消息,则隐式转换成错误结果 return new BResult(false, errorMessage); } public override string ToString() { return Message ?? string.Empty; } } }