Delegates & parameter lists, need help
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?
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
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement