1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- /*-------------------------------------------------------------------------
- * 功能描述: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
- {
- /// <summary>
- /// bool类型结果
- /// </summary>
- 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; }
- /// <summary>
- /// tag
- /// </summary>
- 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;
- }
- }
- }
|