Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - Re: raising events by name

Reply
 
Old 07-07-2008   #1 (permalink)
Dude


 
 

Re: raising events by name

What is the point of reflection if you can't do what you need (raise the
event).

If you are making a game engine and want to expose some classes through
a scripting language and use reflection to make it work, this constraint
will cause hard pain as you will have to implement that dictionnary in
every class you want to expose to the scripting language, which could
easily reach hundreds of classes, not to mention this dictionnary thing
will become a performance issue.



*** Sent via Developersdex http://www.developersdex.com ***

My System SpecsSystem Spec
Old 07-07-2008   #2 (permalink)
Jon Skeet [C# MVP]


 
 

Re: raising events by name

Dude <dude@xxxxxx> wrote:
Quote:

> What is the point of reflection if you can't do what you need (raise the
> event).
There are many things that can be done via reflection. Just because it
doesn't happen to solve your immediate problem doesn't make it useless.
Reflection doesn't solve world hunger, either...
Quote:

> If you are making a game engine and want to expose some classes through
> a scripting language and use reflection to make it work, this constraint
> will cause hard pain as you will have to implement that dictionnary in
> every class you want to expose to the scripting language, which could
> easily reach hundreds of classes, not to mention this dictionnary thing
> will become a performance issue.
Whereas with the approach of adding the Raise part to each event, you'd
have to have the same code repeated for every event. With the
dictionary idea you could even implement a common interface for all of
these classes, so it's clear what's supported.

As for your performance concerns, they seem *incredibly* premature to
me. Dictionary lookups are very cheap - and in the context of
interpreting a scripting language, they're almost guaranteed to pale
into insignificance. Oh, and dictionary lookups are usually cheaper
than using reflection, too

--
Jon Skeet - <skeet@xxxxxx>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon_skeet
C# in Depth: http://csharpindepth.com
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Raising the Text Changed Event of a text box VB Script
Re: raising events by name .NET General
Re: raising events by name .NET General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46