Ejemplo n.º 1
0
 /// <summary>
 /// 把<see cref="IAOPResult"/>接口转换成类实例<see cref="AOPResult"/>
 /// </summary>
 /// <param name="aop"><see cref="IAOPResult"/>接口实例</param>
 /// <param name="initializer">初始器</param>
 /// <returns><see cref="AOPResult"/>实例</returns>
 internal static AOPResult ToAOPResult(IAOPResult aop, Action <AOPResult> initializer)
 {
     if (aop != null)
     {
         var aopResult = aop as AOPResult ?? (AOPResult)Create(aop.ResultNo, aop.ResultDescription, aop.ResultAttachObject, aop.InnerAOPResult, aop.GetResultData());
         initializer?.Invoke(aopResult);
         return(aopResult);
     }
     return(null);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 把<see cref="IAOPResult"/>接口转换成类实例<see cref="AOPResult"/>
 /// </summary>
 /// <param name="aop"><see cref="IAOPResult"/>接口实例</param>
 /// <param name="initializer">初始器</param>
 /// <returns><see cref="AOPResult"/>实例</returns>
 public static AOPResult ToAOPResult(this IAOPResult aop, Action <AOPResult> initializer)
 {
     if (aop != null)
     {
         var result = aop is AOPResult ? (AOPResult)aop : (AOPResult)AOPResult.Create(aop.ResultNo, aop.ResultDescription, aop.ResultAttachObject, aop.InnerAOPResult, aop.GetResultData());
         if (initializer != null)
         {
             initializer(result);
         }
         return(result);
     }
     return(null);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 把<c>IAOPResult</c>转换成<c>IAOPResult&lt;T&gt;</c>
        /// </summary>
        /// <typeparam name="T">附加的泛型</typeparam>
        /// <param name="aop">待转换的<c>IAOPResult</c></param>
        /// <param name="initializer">初始器</param>
        /// <returns>转换后的<c>IAOPResult&lt;T&gt;</c></returns>
        public static IAOPResult <T> ToAOPResult <T>(this IAOPResult aop, Action <AOPResult <T> > initializer)
        {
            if (aop is IAOPResult <T> )
            {
                return((IAOPResult <T>)aop);
            }
            var attachObject = default(T);

            if (aop.ResultAttachObject is T)
            {
                attachObject = (T)aop.ResultAttachObject;
            }
            var result = (AOPResult <T>)AOPResult.Create(aop.ResultNo, aop.ResultDescription, attachObject, aop, aop.GetResultData());

            if (initializer != null)
            {
                initializer(result);
            }
            return(result);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 把<c>IAOPResult</c>转换成<c>IAOPResult&lt;T&gt;</c>
        /// </summary>
        /// <typeparam name="T">附加的泛型</typeparam>
        /// <param name="aop">待转换的<c>IAOPResult</c></param>
        /// <returns>转换后的<c>IAOPResult&lt;T&gt;</c></returns>
        public static IAOPResult <T> ToAOPResult <T>(this IAOPResult aop)
        {
            if (aop is IAOPResult <T> )
            {
                return((IAOPResult <T>)aop);
            }
            var attachObject = default(T);

            if (aop.ResultAttachObject is T)
            {
                attachObject = (T)aop.ResultAttachObject;
            }
            return(AOPResult.Create(aop.ResultNo, aop.ResultDescription, attachObject, aop, aop.GetResultData()));
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 把<c>IAOPResult&lt;Q&gt;</c>转换成<c>IAOPResult&lt;P&gt;</c>
 /// </summary>
 /// <typeparam name="Q">附加的泛型</typeparam>
 /// <typeparam name="P">附加的泛型</typeparam>
 /// <param name="result">待转换的<c>IAOPResult&lt;T&gt;</c></param>
 /// <returns>转换后的<c>IAOPResult&lt;T&gt;</c></returns>
 public static IAOPResult <P> ToAOPResult <Q, P>(this IAOPResult <Q> result)
 {
     return(AOPResult.Create(result.ResultNo, result.ResultDescription, default(P), result, result.GetResultData()));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 把<c>IAOPResult&lt;Q&gt;</c>转换成<c>IAOPResult&lt;P&gt;</c>,其中<typeparamref name="Q"/>从<typeparamref name="P"/>派生
 /// </summary>
 /// <typeparam name="Q">附加的泛型</typeparam>
 /// <typeparam name="P">附加的泛型</typeparam>
 /// <param name="result">待转换的<c>IAOPResult&lt;T&gt;</c></param>
 /// <returns>转换后的<c>IAOPResult&lt;T&gt;</c></returns>
 public static IAOPResult <P> CovertTo <Q, P>(this IAOPResult <Q> result) where Q : P
 {
     return(AOPResult.Create <P>(result.ResultNo, result.ResultDescription, result.ResultAttachObjectEx, result, result.GetResultData()));
 }