zoukankan      html  css  js  c++  java
  • 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(".") + 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;
  • 相关阅读:
    HDU-5384
    UVALive 5099
    ZOJ-2753
    HUD-5379
    HDU-5360
    HDU-5351
    HDU-5335
    HDU-5317
    HDU-2487
    常用十六进制颜色对照表代码查询
  • 原文地址:https://www.cnblogs.com/lzhp/p/5756109.html
Copyright © 2011-2022 走看看