Sign in to follow this  
NEXUSKill

Delegates & parameter lists, need help

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this