I want to call multiple method dynamically by respecting a certain order. The idea I had was to create a dynamic list of string that is sorted each time depending of a certain values on my database, the result will look something like this:
["InvokingMethod1","InvokingMethod3","InvokingMethod4"....] // this may vary
This list is extracted from a list of object from my database :
"affichages": [
{
"bloc_affichage": {
"nom": "affichage_f",
"active": true,
"ordre": 1,
"methodName":"InvokingMethod1"
}
},
{
"bloc_affichage": {
"nom": "affichage_sf",
"active": false,
"ordre": 2,
"methodName":"InvokingMethod7"
}
},
{
"bloc_affichage": {
"nom": "affichage_se",
"active": false,
"ordre": 3,
"methodName":"InvokingMethod6"
}
},
{
"bloc_affichage": {
"nom": "affichage_g",
"active": true,
"ordre": 4,
"methodName":"InvokingMethod3"
}
},
{
"bloc_affichage": {
"nom": "affichage_t",
"active": true,
"ordre": 5,
"methodName":"InvokingMethod4"
}
}
]
by itarating through the list affichages
and sorted it by order and active set to true so I can get this sorted List, I want to call each method that is related to each value methodName
.
static void InvokingMethodX(Something to_Do)
{
Work1(table);
Work2(table);
WorkN(table);
}
In the end I will have this Order:
InvokingMethod1(Something to_Do);
InvokingMethod3(Something to_Do);
InvokingMethod4(Something to_Do);
Is there a way to do properly achieve this ?
Edit 1 :
Argument type 'void' is not assignable to parameter type 'System.Action'