Added new method to get part of the stack.
This commit is contained in:
parent
7b0b0f25e3
commit
dda71c5d1b
@ -61,6 +61,49 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
public static void ShowStackFirstLocal(string str)
|
||||
{
|
||||
Console.WriteLine(str + " " + StackToStringLocal(3,0));
|
||||
}
|
||||
public static void ShowStackLocal(string str,int start)
|
||||
{
|
||||
Console.WriteLine(str + " " + StackToStringLocal(start,1));
|
||||
}
|
||||
public static void ShowStackLocal(string str,int start, int limit)
|
||||
{
|
||||
Console.WriteLine(str + " " + StackToStringLocal(start, limit));
|
||||
}
|
||||
private static string StackToStringLocal(int start, int limit)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
string sep = "Local Method - ";
|
||||
StackTrace st = new StackTrace(true);
|
||||
StackFrame[] sfs = st.GetFrames();
|
||||
int count = 0;
|
||||
int localCount = 0;
|
||||
foreach (StackFrame sf in sfs)
|
||||
{
|
||||
count++;
|
||||
if (count > start)
|
||||
{
|
||||
if (sf.GetFileLineNumber() != 0)
|
||||
{
|
||||
string sMethod = sf.GetMethod().Name;
|
||||
string sNamespace = sf.GetMethod().ReflectedType.Namespace;
|
||||
string sType = sf.GetMethod().ReflectedType.Name;
|
||||
sMethod += string.Format(" {0}[{1}]", sf.GetFileName(), sf.GetFileLineNumber());
|
||||
sb.Append(sep + string.Format("{0}.{1}.{2}", sNamespace, sType, sMethod));
|
||||
localCount ++;
|
||||
if (localCount >= limit)
|
||||
return sb.ToString();
|
||||
sep = "\r\n" + "".PadRight(localCount *2);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (localCount > 0)
|
||||
return sb.ToString();
|
||||
return "No Local Method";
|
||||
}
|
||||
private static StackFrame[] _LastSFS;
|
||||
private static int MatchingStackFrame(StackFrame[] sfs)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user