View Single Post
Old Mar 24th, 2008, 4:23 PM   #4
lectricpharaoh
SEXY SHOELESS GOD OF WAR!
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Wet west coast of Canada
Posts: 1,198
Rep Power: 5 lectricpharaoh will become famous soon enough
Re: Reflection Casting

Ahh, so you don't need to determine the 'cast to' type at runtime. All you need to do is verify it implements the specified interface.

Say your interface is IPlugin and the programmer has an object plugin, which is an instance of their class that is supposed to implement the interface.. Something like this should work:
C# Syntax (Toggle Plain Text)
  1. if(plugin is IPlugin)
  2. // implements the interface
  3. else
  4. // oops
Perhaps include this kind of logic when you're registering the plugin.
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot.
- Vaarsuvius, Order of the Stick
lectricpharaoh is offline   Reply With Quote