Panda II dotnet micro framework function call question

My application for the Panda II needs to dynamically determine what function to call in a main routine. The basic construction is such that an end user will save configuration maps that allow them to assign different functionality to switches and displays controlled by the Panda II. So at runtime, the program will load the map, and, for example in an interrupt for a switch press, will look up the function name mapped to that switch and execute that function.

In C# / dotnet 4.0 I could use the Func(TResult) delegate and pass the function name as a string variable array element that was loaded from the saved map. Any ideas on how I could replicate that without generics in the dotnet micro framework?

Thanks for any advice!

Scott

You can use reflection.

Take a look in the following codeshare:

http://www.tinyclr.com/codeshare/entry/200

There is a code that finds a method using just the name and then later invokes it using reflection classes.

Got it - I should be able to do something like this, correct?

void Process_Input(int index, int userParam)
{
Type thisType = this.GetType();
MethodInfo theMethod = thisType.GetMethod(Method_List[index]);
theMethod.Invoke(this, userParam);
}

Where “Method_List[index]” points to a method name that is accessed when switch input is processed, e.g.

Method_List[0] = "Do_Something_Cool"
Method_List[1] = “Do_Something_Else”

and the method signature matches i.e.

void Do_Something_Cool(int userParam)
{

Do cool stuff here…
}

Look about right?

Thanks for the tip!

Scott

Yes, something like that. I would use more error checking.

As a side note. You can make your post more readable by enclosing the C# statements using code tags.