using System.Diagnostics;
using System.Web.UI;
public static class DebugExtensions
{
private static string traceIndent = "";
public static void traceEnter(this TemplateControl self, params object[] args)
{
StackTrace st = new StackTrace();
string method = st.GetFrame(1).GetMethod().Name;
string parent_method = st.GetFrame(2).GetMethod().Name;
string filename = st.GetFrame(2).GetFileName();
int fileline = st.GetFrame(2).GetFileLineNumber();
if (args != null && args.Length > 0)
{
string arguments = "";
foreach (object arg in args) arguments += ", " + (arg ?? "").ToString();
method += "(" + arguments.Substring(2) + ")";
}
Debug.WriteLine(traceIndent + ">> " + method + " (called from " + parent_method + "@" + filename + ":" + fileline + ")");
traceIndent += " ";
}
public static void traceExit(this TemplateControl self)
{
StackTrace st = new StackTrace();
traceIndent = traceIndent.Substring(2);
Debug.WriteLine(traceIndent + "<< " + st.GetFrame(1).GetMethod().Name);
}
}