private static bool hasQueryFromView(CallingMethodStackTrace item)
        {
            if (item == null || item.CallingMethodInfoList == null)
                return false;

            foreach (var info in item.CallingMethodInfoList)
            {
                if (string.IsNullOrWhiteSpace(info.CallingFile))
                    continue;

                var ext = Path.GetExtension(info.CallingFile);
                if (string.IsNullOrWhiteSpace(ext))
                    continue;

                ext = ext.ToLowerInvariant();

                if (_viewExtensions.Contains(ext))
                {
                    return true;
                }
            }

            return false;
        }
Exemple #2
0
        public CallingMethodStackTrace GetCallingMethodInfo(bool onlyIncludeInfoWithFileLine = false)
        {
            var results = new CallingMethodStackTrace();

            var stackTrace = new StackTrace(true);
            var frameCount = stackTrace.FrameCount;

            var info = new StringBuilder();
            var prefix = "-- ";
            for (var i = frameCount - 1; i >= 0; i--)
            {
                var sf = stackTrace.GetFrame(i);
                var methodInfo = getStackFrameInfo(sf, onlyIncludeInfoWithFileLine);
                if (methodInfo == null || string.IsNullOrWhiteSpace(methodInfo.StackTrace))
                    continue;

                info.AppendLine(prefix + methodInfo.StackTrace);
                prefix = "-" + prefix;

                results.CallingMethodInfoList.Add(methodInfo);
            }

            var stackTraceString = info.ToString().Trim();
            if (string.IsNullOrWhiteSpace(stackTraceString))
            {
                stackTraceString = string.Format("no-info @{0}", Guid.NewGuid());
            }
            results.StackTraceHash = stackTraceString.ComputeHash();

            return results;
        }