/* ==============================================================================
 * 功能描述：
 * 创 建 者：Garrett
 * 创建日期：2019/5/31 16:24:04
 * ==============================================================================*/


using System;
using MBIRevitBase;

namespace ServiceRevitLib.Mode
{
    /// <summary>
    /// CheckResultBase
    /// </summary>
    public class ResultBase
    {
        public ResultBase()
        {
            Result = ResultState.Success;
        }
        /// <summary>
        /// 异常结果
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        public static ResultBase Exception(string msg)
        {
            return new ResultBase(){Result = ResultState.Failure,ResultMsg = msg};
        }
        /// <summary>
        /// 成功或失败结果描述
        /// </summary>
        public string ResultMsg { get; set; }

        /// <summary>
        /// 结果
        /// </summary>
        public ResultState Result { get; set; }

        public static implicit operator ResultBase(BResult result)
        {
            return new ResultBase()
            {
                ResultMsg = result.Message,
                Result = (ResultState)(Convert.ToInt32(result.IsSuccessed))
            };
        }

    }
}
