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

时间:2023-03-09 16:41:27
AOP如何在业务结束时,根据参入参数和返回结果添加日志
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(".") + ) + "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;