This commit is contained in:
@@ -29,13 +29,62 @@ namespace Volian.Controls.Library
|
||||
StackTrace st = new StackTrace(true);
|
||||
StackFrame[] sfs = st.GetFrames();
|
||||
int ii = 0;
|
||||
string sLast = "";
|
||||
string sThis = "";
|
||||
int imax = MatchingStackFrame(sfs);
|
||||
foreach (StackFrame sf in sfs)
|
||||
{
|
||||
if (imax == 0)
|
||||
sb.Append(string.Format("\r\n{0}---------", "".PadLeft(ii++ * 2)));
|
||||
imax--;
|
||||
if (ii < 2) ii++;
|
||||
else if (sf.GetFileLineNumber() != 0)
|
||||
sb.Append(string.Format("\r\n{0}{1}", "".PadLeft(ii++ * 2), sf.ToString().TrimEnd(" \r\n".ToCharArray())));
|
||||
else
|
||||
{
|
||||
string sMethod = sf.GetMethod().Name;
|
||||
string sNamespace = sf.GetMethod().ReflectedType.Namespace;
|
||||
string sType = sf.GetMethod().ReflectedType.Name;
|
||||
if (sf.GetFileLineNumber() != 0)
|
||||
{
|
||||
sMethod += string.Format(" {0}[{1}]", sf.GetFileName(), sf.GetFileLineNumber());
|
||||
sThis = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
sThis = sNamespace;
|
||||
}
|
||||
if (sLast == sThis && sThis != "")
|
||||
sb.Append(string.Format("\t*.{0}.{1}", sType, sMethod));
|
||||
else
|
||||
sb.Append(string.Format("\r\n{0}{1}.{2}.{3}", "".PadLeft(ii++ * 2), sNamespace, sType, sMethod));
|
||||
}
|
||||
sLast = sThis;
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
private static StackFrame [] _LastSFS;
|
||||
private static int MatchingStackFrame(StackFrame[] sfs)
|
||||
{
|
||||
int iFound = -1;
|
||||
if (_LastSFS != null)
|
||||
{
|
||||
// start at the far end and work backward
|
||||
for (int i = 1; iFound < 0 && i <= sfs.Length && i <= _LastSFS.Length; i++)
|
||||
{
|
||||
if (!Match(sfs[sfs.Length - i],_LastSFS[_LastSFS.Length - i]))
|
||||
iFound = 1+ sfs.Length - i;
|
||||
}
|
||||
}
|
||||
if (iFound < 0) iFound = sfs.Length;
|
||||
_LastSFS = (StackFrame[])sfs.Clone();
|
||||
return iFound;
|
||||
}
|
||||
|
||||
private static bool Match(StackFrame stackFrame1, StackFrame stackFrame2)
|
||||
{
|
||||
if (stackFrame1.GetMethod().Name != stackFrame2.GetMethod().Name) return false;
|
||||
if (stackFrame1.GetMethod().DeclaringType.FullName != stackFrame2.GetMethod().DeclaringType.FullName) return false;
|
||||
if (stackFrame1.GetILOffset() != stackFrame2.GetILOffset()) return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user