reflection!!

  • Thread starter Thread starter cs
  • Start date Start date
C

cs

I want to be able to write a little reflection program that can handdle any
kind of Event. So it must be able to add an event handler to an event it has
never seen before, this is a little tough to do since different events have
different signatures! Any idea how to do this? what I do witht he params
passed by teh event doesnt matter as long as I can get the event!
 
I wrote a dynamic delegate adapter that you could use or rework to fit your
needs. It's essential purpose was running any delegate as a ThreadStart or
several other well-known delegates:
 
I read a little bit of your code, but I am not sure its gonna help me.
What I really need to do is on the fly, discover events on a class and
generate methods that will handle those events, but this needs to happen on
the fly, either by generating the code and using the compiler classes or
using the emit classes and generating the IL, I am evaluating both right
now.
 
Okay, that requirement reads a bit differently than your OP, at least to me.
What is the ultimate goal (i.e. the business goal) you are trying to
accomplish here? Are you certain that generating code is the right idea?
Would you generate code for this problem regardless of whether or not you
had to hook up to events you'd never seen before? Or do you just want to
call an already known method via any event? Or something else.

Richard
 
I cant go into much detail but I am trying to hook up some different object
instances together on runtime. This connection will be done via events,
however events will not always mean they are handled based ont ehir
signature. Lets say there is an event X that object A throws, maybe I want
to call method Y on object B when this happens. This has to all be done on
runtime, not even the assemblies of A or B will be known till runtime, and
the signature of the delegate of event X will not match method Y. So I will
have to capture event X and call method Y, I know how to do all that other
than creating the method on runtime capable of handling any event X.
Hope this was clearer! sorry for not being clear before.
 
Back
Top