ApiHelper

时间:2016-06-15 22:02:33   收藏:0   阅读:863
    public static class ApiHelper
    {
        public static ReslultInfo<K> Try<K>(Action<ReslultInfo<K>> action) 
        {
            var r = new ReslultInfo<K>();
            try
            {
                action(r);
            }
            catch (Exception ex)
            {
                r.code = ReslultCode.error;
                r.desc = ex.Message;
            }
            return r;
        }
    }
    public enum ReslultCode
    {
        sucess,
        error
    }
    public class ReslultInfo<T>
    {
        public ReslultInfo()
        {
            code = ReslultCode.sucess;
            desc = "";
        }
        //result:sucess/error
        public ReslultCode code { get; set; }
        public string desc { get; set; }

        public T Data { get; set; }
    }

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!