/// <summary> /// 构造函数 /// </summary> /// <param name="resultNo">返回代码</param> /// <param name="resultDescription">对应的描述信息</param> /// <param name="resultAttachObject">相应的附加信息</param> /// <param name="innerAOPResult">内部AOPResult</param> public AOPResult(int resultNo, string resultDescription, object resultAttachObject, AOPResult innerAOPResult) { this.resultNo = resultNo; this.resultDescription = resultDescription; this.resultAttachObject = resultAttachObject; this.innerAOPResult = innerAOPResult; }
public void TestAOPResultConverting() { var ap = new AOPResult<int>(); var ap1 = (IAOPResult<int>)ap; AOPResult aop = ap; aop.ResultAttachObject = 1F; Assert.IsTrue(aop.ResultAttachObject is int); Assert.IsTrue(ap1.ResultAttachObjectEx == 1); }
/// <summary> /// 把<c>IAOPResult<Q></c>转换成<c>IAOPResult<P></c> /// </summary> /// <typeparam name="Q">附加的泛型</typeparam> /// <typeparam name="P">附加的泛型</typeparam> /// <param name="result">待转换的<c>IAOPResult<T></c></param> /// <returns>转换后的<c>IAOPResult<T></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())); }
/// <summary> /// 把<c>IAOPResult<Q></c>转换成<c>IAOPResult<P></c>,其中<typeparamref name="Q"/>从<typeparamref name="P"/>派生 /// </summary> /// <typeparam name="Q">附加的泛型</typeparam> /// <typeparam name="P">附加的泛型</typeparam> /// <param name="result">待转换的<c>IAOPResult<T></c></param> /// <returns>转换后的<c>IAOPResult<T></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())); }