L
lucius
ASP.NET 2.0
I have web controls with their own event handlers that I need to
funnel into a central handler, eg
TypicalEvent( object sender, TypicalEventArgs e )
{
HandleEverything( sender , (EventArgs)e );
}
LinkEvent( object sender, LinkEventArgs e )
{
HandleEverything( sender , (EventArgs)e );
}
SpecialEvent( object sender, SpecialEventArgs e )
{
HandleEverything( sender , (EventArgs)e );
}
And the central event handler is
HandleEverything( object sender , EventArgs e )
{
}
Within "HandleEverything", I would like to know the original Type of
what is in EventArgs and then cast it to the proper Type, because if
it's TypicalEventArgs there is a Value property, if it is
LinkEventArgs there is an AnchorText property, etc.
How can I use Reflection (or Generics?) to "uncast" and use?
Thanks.
I have web controls with their own event handlers that I need to
funnel into a central handler, eg
TypicalEvent( object sender, TypicalEventArgs e )
{
HandleEverything( sender , (EventArgs)e );
}
LinkEvent( object sender, LinkEventArgs e )
{
HandleEverything( sender , (EventArgs)e );
}
SpecialEvent( object sender, SpecialEventArgs e )
{
HandleEverything( sender , (EventArgs)e );
}
And the central event handler is
HandleEverything( object sender , EventArgs e )
{
}
Within "HandleEverything", I would like to know the original Type of
what is in EventArgs and then cast it to the proper Type, because if
it's TypicalEventArgs there is a Value property, if it is
LinkEventArgs there is an AnchorText property, etc.
How can I use Reflection (or Generics?) to "uncast" and use?
Thanks.