Thursday, December 01, 2005

Where Am I..?

Dbg.YouAreHere();


-------------------------------------------------------------------------------------------------------
You are in
- member: 'Int32 Main(System.String[])'
- class: 'YourNamespace.YourClass, YourAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
-------------------------------------------------------------------------------------------------------



using System;
using System.Diagnostics;
using System.Reflection;

internal sealed class Dbg
{
  [ConditionalAttribute("DEBUG")]
  public static void YouAreHere()
  {
    try
    {
      StackFrame f = new StackFrame(1);
      MethodBase m = f.GetMethod();
      Type t = m.DeclaringType;
      String n = t.AssemblyQualifiedName;

      Debug.WriteLine(String.Format(@"{0}
You are in
-  member: '{1}'
-   class: '{2}'
{0}"
        , new String('-', 12 + n.Length)
        , m.ToString()
        , t.AssemblyQualifiedName));
    }
    catch {}
  }
}

3 comments:

Anonymous said...

Well done!
[url=http://tkoptuol.com/rdfk/mxos.html]My homepage[/url] | [url=http://tszzvfjz.com/cqvu/izpz.html]Cool site[/url]

Anonymous said...

Nice site!
My homepage | Please visit

Anonymous said...

Well done!
http://tkoptuol.com/rdfk/mxos.html | http://rqlvciuq.com/aqfp/koxk.html