I have a function which initiates commands for a command class. Since there are many commands to initiate, writing code for each one would be tedious.
The function definition is as follows-
private static void InitCommand(KeyGesture input, String text, String name)
{
InputGestureCollection inputs = new InputGestureCollection();
inputs.Add(input);
Type t = typeof(UploadCommands);
t.GetMember(name);
(RoutedUICommand)t.GetMember(name) = new RoutedUICommand(text, name, typeof(UploadCommands), inputs);
}
Now, my problem is that I wish to reference the commands dynamically. I pass in the command name, it references the public static RoutedUICommand variable.
In PHP, the equivalent would be-
$class->$member = "Blah, blah";
I can't figure out how this would be done in C#.