/// <summary> /// 默认初始化一个失败的返回值 /// </summary> /// <typeparam name="T"></typeparam> /// <returns></returns> public static DataShell <T> CreateFail <T>() { var t = new DataShell <T>(); t.Failed(); return(t); }
/// <summary> /// 默认初始化一个成功的返回值 /// </summary> /// <typeparam name="T"></typeparam> /// <returns></returns> public static DataShell <T> CreateSuccess <T>() { var t = new DataShell <T>(); t.Succeed(); return(t); }
/// <summary> /// 默认初始化一个失败的返回值,并写入 info /// </summary> /// <typeparam name="T"></typeparam> /// <param name="info"></param> /// <returns></returns> public static DataShell <T> CreateFail <T>(IList <string> infos) { var t = new DataShell <T>(); t.Failed(infos); return(t); }
/// <summary> /// 默认初始化一个失败的返回值,并写入 info /// </summary> /// <typeparam name="T"></typeparam> /// <param name="info"></param> /// <returns></returns> public static DataShell <T> CreateFail <T>(string info) { var t = new DataShell <T>(); t.Failed(info); return(t); }
/// <summary> /// 默认初始化一个失败的数据壳,写入exception /// </summary> /// <typeparam name="T"></typeparam> /// <param name="exception"></param> /// <returns></returns> public static DataShell <T> CreateFail <T>(Exception exception) { var t = new DataShell <T>(); t.Failed(exception.Message); t.AddInfoDetail(exception.StackTrace); //t.ExceptionList.Add(exception); return(t); }
/// <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); }