示例#1
0
        public static async Task <ApiMessage> Wrap <T>(Func <Task <T> > func)
        {
            var apiMsg = new ApiMessage();

            try
            {
                apiMsg.Data = await func();
            }
            catch (Exception exc)
            {
                apiMsg.SetFault(exc.StackTrace);
            }
            return(apiMsg);
        }
示例#2
0
        public static async Task <ApiMessage> Wrap(Func <Task> action)
        {
            var apiMsg = new ApiMessage();

            try
            {
                await action();
            }
            catch (Exception exc)
            {
                apiMsg.SetFault(exc);
            }

            return(apiMsg);
        }
示例#3
0
        public static async Task <ApiMessage> WrapAndTuple <T>(Func <Task <Tuple <List <T>, int> > > func)
        {
            var apiMsg = new ApiMessage();

            try
            {
                var tupleData = await func();

                apiMsg.Data  = tupleData.Item1;
                apiMsg.Count = tupleData.Item2;
            }
            catch (Exception exc)
            {
                apiMsg.SetFault(exc.StackTrace);
            }
            return(apiMsg);
        }