0

My goal is to write code like this:

var ei = new EventInterceptor(_someInstance);
ei.EventFired += (s,e) => { Logger.Log("{0} fired {1}", s.ToString(), e.ToString(); }

I think I can write this up in reflection logic, but if there's something out there I'd rather use it. This would be incredibly useful (i think) for studying complicated objects like in ado.net and the winforms datagridview...

Aaron Anodide
  • 16,906
  • 15
  • 62
  • 121
  • 1
    Hi, have you seen this article at CodeProject? http://www.codeproject.com/KB/cs/eventtracingviareflection.aspx (Tracing Events Raised by Any C# Object) – Kimberly Apr 20 '11 at 03:05
  • Thanks, that looks like my answer, if you want to put it down i'll mark it as such. – Aaron Anodide Apr 20 '11 at 03:07
  • If you're sure. You might wait awhile and see if anything better is suggested by some experts... – Kimberly Apr 20 '11 at 03:15

1 Answers1

1

A Reflection-based event tracer is available from davidbakin @ CodeProject:

Tracing Events Raised by Any C# Object

Alternatives: if your platform is Vista or Windows 7, you might try Event Tracing for Windows (ETW), though it seems like the learning curve is a bit steep.

Also, a suggestion for an event logger class (probably something similar to the Code Project article) was given in the answer to a related question.

Community
  • 1
  • 1
Kimberly
  • 2,657
  • 2
  • 16
  • 24