Added new Property CalledFrom which will return the first local in the stack
This commit is contained in:
parent
9180fba5ec
commit
c7294d5ffd
@ -104,6 +104,31 @@ namespace Volian.Controls.Library
|
||||
return sb.ToString();
|
||||
return "No Local Method";
|
||||
}
|
||||
public static string CalledFrom
|
||||
{
|
||||
get
|
||||
{
|
||||
StackTrace st = new StackTrace(true);
|
||||
StackFrame[] sfs = st.GetFrames();
|
||||
int count = 0;
|
||||
foreach (StackFrame sf in sfs)
|
||||
{
|
||||
if (sf.GetFileLineNumber() != 0)
|
||||
{
|
||||
count++;
|
||||
{
|
||||
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());
|
||||
if (count > 3)
|
||||
return string.Format("{0}.{1}.{2}", sNamespace, sType, sMethod);
|
||||
}
|
||||
}
|
||||
}
|
||||
return "No Local Method";
|
||||
}
|
||||
}
|
||||
private static StackFrame[] _LastSFS;
|
||||
private static int MatchingStackFrame(StackFrame[] sfs)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user