I have ~100 tasks described in Tasks.xml. Each task, has some fields such as name, index and priority. In the program eventually each task is represented by the Class Task. I got a requirement to add the ability to run a handler per each task (there are ~15 different possible handlers, some are common). I decided to add to each task in the xml a Handler attriblute:
<Task Name="Task1" Handler="TaskHandler_A">
and to the Class Task add a method named as the Handler attribute value:
public class Task
{
string name;
// some more fields
void TaskHandler_A()
{
}
// some more handlers
//
void TaskHandler_P()
{
}
}
That i should run in the program to handle this task at some point (each handler method is about 10 code lines). This should solve the requirfement, however it doesn't seem generic enough, since the code discloses the name of the handlers. Is there a more elegant/generic solution for this requirement, such that i will not need to disclose the Handler names inside the Code?