Esempio n. 1
0
        /// <summary>
        /// 转化到结果实体
        /// </summary>
        /// <typeparam name="TPara"></typeparam>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="res"></param>
        /// <param name="func"></param>
        /// <returns></returns>
        public static TResult ConvertToResultInherit <TPara, TResult>(this ResultMo <TPara> res,
                                                                      Func <TPara, TResult> func)
            where TResult : ResultMo, new()
        {
            if (func != null && res.IsSuccess())
            {
                return(func(res.data));
            }

            return(new TResult()
            {
                ret = res.ret,
                msg = res.msg
            });
        }
Esempio n. 2
0
        /// <summary>
        /// 转化到结果实体
        /// </summary>
        /// <typeparam name="TPara"></typeparam>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="res"></param>
        /// <param name="func"></param>
        /// <returns></returns>
        public static ResultMo <TResult> ConvertToResult <TPara, TResult>(this ResultMo <TPara> res,
                                                                          Func <TPara, TResult> func)
        {
            var ot = new ResultMo <TResult>
            {
                ret = res.ret,
                msg = res.msg
            };

            if (func != null && res.IsSuccess())
            {
                ot.data = func(res.data);
            }

            return(ot);
        }