AOP如何在业务结束时,根据参入参数和返回结果添加日志

it2022-05-07  49

IMethodReturn retvalue = getNext()(input, getNext); if (retvalue.Exception != null) { System.IO.File.AppendAllText("a.txt", retvalue.Exception.ToString()); retvalue.Exception = null; } if (retvalue != null) { var dll = Assembly.Load("AopIntercept"); Type tx = dll.GetType("AopIntercept."+input.Target.ToString().Substring(input.Target.ToString().LastIndexOf(".") + 1) + "Log"); MethodInfo mf = tx.GetMethod("Log"); List<object> list = new List<object>(); list.Add(retvalue.ReturnValue); foreach (var item in input.Inputs) { list.Add(item); } mf.Invoke(null, list.ToArray()); } return retvalue;

 

转载于:https://www.cnblogs.com/lzhp/p/5756109.html


最新回复(0)