Delegates & parameter lists, need help

Started by
3 comments, last by NEXUSKill 15 years ago
I'm working on a small XNA 2d game framework, I came across a problem when implementing the Input system, the system is quite powerful and flexible but one feature it lacks is the ability to have custom parameter lists for delegate functions. Right now the delegate functions called upon input events have no parameters, and deciding on the types of parameters is something I want to leave to the user of the system, not to the system itself. Is there a way to send into a function an undetermined ammount and type of parameters so that it may internaly cast them to the proper types and do whatever with them?
Game making is godlike

LinkedIn profile: http://ar.linkedin.com/pub/andres-ricardo-chamarra/2a/28a/272


Advertisement
I dont see how that will work out, the point is that I need the same delegate to be able to recieve very different sets of arguments, IE an argument list that only the function called by the delegate knows what they are, how many and how to use them
Game making is godlike

LinkedIn profile: http://ar.linkedin.com/pub/andres-ricardo-chamarra/2a/28a/272


If you have the delegate take a single object parameter, the calling methods can pass in any arbitrary container class containing all the parameters you need. The receiving delegate will need to know to cast to the correct type though.
Mike Popoloski | Journal | SlimDX
To have argument lists for a function, the syntax is: params object[] args

More info here
Thanks both of you, those were headshot answers, will look into it
Game making is godlike

LinkedIn profile: http://ar.linkedin.com/pub/andres-ricardo-chamarra/2a/28a/272


This topic is closed to new replies.

Advertisement