Exemple #1
0
 /// <summary>
 /// 对成功结果进行处理
 /// </summary>
 /// <typeparam name="T">泛型类型</typeparam>
 /// <param name="aop"><see cref="IAOPResult{T}"/>实例</param>
 /// <param name="handler">处理委托</param>
 /// <returns><see cref="IAOPResult{T}"/>实例</returns>
 public static IAOPResult <T> Success <T>(this IAOPResult <T> aop, Func <IAOPResult <T>, IAOPResult <T> > handler)
 {
     if (aop.IsSuccess() && handler != null)
     {
         aop = handler(aop);
     }
     return(aop);
 }
Exemple #2
0
 /// <summary>
 /// 对成功结果进行处理
 /// </summary>
 /// <typeparam name="T">泛型类型</typeparam>
 /// <param name="aop"><see cref="IAOPResult{T}"/>实例</param>
 /// <param name="handler">处理委托</param>
 /// <returns><see cref="IAOPResult{T}"/>实例</returns>
 public static IAOPResult <T> Success <T>(this IAOPResult <T> aop, Action <IAOPResult <T> > handler)
 {
     if (aop.IsSuccess() && handler != null)
     {
         handler(aop);
     }
     return(aop);
 }
Exemple #3
0
 /// <summary>
 /// 对成功结果进行处理
 /// </summary>
 /// <param name="aop"><see cref="IAOPResult"/>实例</param>
 /// <param name="handler">处理委托</param>
 /// <returns><see cref="IAOPResult"/>实例</returns>
 public static IAOPResult Success(this IAOPResult aop, Func <IAOPResult, IAOPResult> handler)
 {
     if (aop.IsSuccess() && handler != null)
     {
         aop = handler(aop);
     }
     return(aop);
 }
Exemple #4
0
        protected virtual object ResultHandle(IAOPResult aop, Type returnType, ISerializer serializer)
        {
#if DEBUG
            LogService.WriteLog(this, LogLevel.DEBUG, aop.ToString());
#endif
            object returnValue = null;
            if (typeof(IAOPResult).IsAssignableFrom(returnType))
            {
                returnValue = aop;
                if (returnType.IsGenericType && aop.IsUnSuccess())                 //要求返回的是泛型,并且返回失败
                {
                    var aopType = aop.GetType();
                    if (!aopType.IsGenericType)                     //实际获取到的不是泛型,需要转换
                    {
                        var rt       = typeof(AOPResult <>).MakeGenericType(returnType.GetGenericArguments());
                        var instance = (AOPResult)TypeHelper.CreateObject(rt, null, false);
                        instance.ResultNo          = aop.ResultNo;
                        instance.ResultDescription = aop.ResultDescription;
                        returnValue = instance;
                    }
                }
            }
            else if (aop.IsSuccess())
            {
                if (returnType != typeof(void))
                {
                    if (aop.ResultAttachObject != null)
                    {
                        returnValue = returnType.IsInstanceOfType(aop.ResultAttachObject) ? aop.ResultAttachObject : serializer.Convert(aop.ResultAttachObject, returnType, null);
                    }
                }
            }
            else
            {
                throw new RemotingException(aop.ResultNo, aop.ResultDescription);
            }
            return(returnValue);
        }