I have a message coming into my C# app which is an object serialized as JSON, when i de-serialize it I have a \"Name\" string
and a \"Payload\" string[]
My solution with input parameters, and a int as Key of Invoke:
private static Dictionary MethodDictionary(string param1, string param2, int param3) => new Dictionary
{
{1 , () => Method1(param1, param2, param3) },
{2 , () => Method2(param1, param2, param3) },
{3 , () => Method3(param1, param2, param3) },
{4 , () => Method4(param1, param2, param3) },
{5 , () => Method5(param1, param2, param3) }
};
And to invoke a method:
var methodDictionary = MethodDictionary("param1", "param2", 1);
methodDictionary[2].Invoke();
This will execute Method2.
Hope it helps!