예제 #1
0
        /// <summary>
        /// 生成一个Task:ActionResult:DataShell:T 泛型;
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="self"></param>
        /// <param name="func"></param>
        /// <returns></returns>
        public static Task <ActionResult <IDataShell <T> > > ToTaskActResult <T>(this IDataShell <T> self, Func <ActionResult <IDataShell <T> > > func = null)
        {
            if (func.IsNull())
            {
                return(Task <ActionResult <IDataShell <T> > > .Run <ActionResult <IDataShell <T> > >(() => new ActionResult <IDataShell <T> >(self)));

                //return new Task<ActionResult<DataShell<T>>>();
            }
            else
            {
                return(Task <ActionResult <IDataShell <T> > > .Run <ActionResult <IDataShell <T> > >(func));

                //return new Task<ActionResult<DataShell<T>>>(func);
            }
        }
예제 #2
0
        /// <summary>
        /// 用新的Data数据类型,完全转换一个新的类型的数据外壳
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="self"></param>
        /// <returns></returns>
        public static IDataShell <TTag> ToNewShell <TSrc, TTag>(this IDataShell <TSrc> self, TTag newdata = default(TTag))
        {
            IDataShell <TTag> target = new DataShell <TTag>();

            target.Code          = self.Code;
            target.Data          = newdata;
            target.ExceptionList = self.ExceptionList;
            target.Info          = self.Info;
            target.InfoDetail    = self.InfoDetail;
            target.Infos         = self.Infos;
            target.Operator      = self.Operator;
            target.Status        = self.Status;
            target.Success       = self.Success;
            target.Time          = self.Time;
            target.Version       = self.Version;
            return(target);
        }
예제 #3
0
 /// <summary>
 /// 相应数据转换
 /// </summary>
 /// <typeparam name="TIn"></typeparam>
 /// <typeparam name="TOut"></typeparam>
 /// <param name="src"></param>
 /// <returns></returns>
 public static IDataShell <TOut> MapResult <TIn, TOut>(IDataShell <TIn> src)
 {
     if (src.Data.IsNull())
     {
         var res = new DataShell <TOut>();
         res.Code          = src.Code;
         res.ExceptionList = src.ExceptionList;
         res.Info          = src.Info;
         res.Infos         = src.Infos;
         res.Operator      = src.Operator;
         res.Status        = src.Status;
         res.Success       = src.Success;
         res.Time          = src.Time;
         res.Version       = src.Version;
         res.Data          = default(TOut);
         return(res);
     }
     else
     {
         return(null);// return Mapper.Map<DataShell<TIn>, DataShell<TOut>>(src);
     }
 }