Exemple #1
0
        /// <summary>
        /// 从系统的跟踪堆栈中获取堆栈信息
        /// </summary>
        /// <param name="pStackTrace"></param>
        /// <param name="pJumpOutTypes"></param>
        /// <returns></returns>
        private static StackTraceInfo[] createStackTraceInfos(StackTrace pStackTrace)
        {
            List <StackTraceInfo> result = new List <StackTraceInfo>();
            //
            StackTrace st     = pStackTrace;
            var        frames = st.GetFrames();
            //
            var startIndex = findSelfCodeBoundary(frames);

            for (int i = 0; i <= startIndex; i++)
            {
                var frame  = frames[i];
                var method = frame.GetMethod();
                //组织跟踪堆栈信息
                StackTraceInfo info = new StackTraceInfo(method);
                info.LineNumber        = frame.GetFileLineNumber();
                info.ClassFileLocation = frame.GetFileName();
                //检查该方法是否需要剔除
                if (isSkip(info))
                {
                    continue;
                }
                //
                result.Add(info);
            }
            //
            return(result.ToArray());
        }
Exemple #2
0
 /// <summary>
 /// 是否要剔除?
 /// </summary>
 /// <param name="pStackTraceInfo"></param>
 /// <returns></returns>
 private static bool isSkip(StackTraceInfo pStackTraceInfo)
 {
     if (pStackTraceInfo != null)
     {
         var methodFullName = pStackTraceInfo.GetFullMethodName();
         foreach (var item in SKIPPED_METHOD_FULL_NAMES)
         {
             if (methodFullName == item)
             {
                 return(true);
             }
         }
     }
     return(false);
 }