|
I have an enum with lots of elements in it. Now I need to invoke correspondent method for each enum (myEnum) element.
I created a Dictionary (myDictionary) with myEnum as key and Action as value.
But there is a problem that I am facing now, that is, there are some methods which needs some input parameters and some dont but all returns string. And here, Action supports delegate for no input parameter or upto four parameters. Is there any generic way to accomodate all of my methods in my myDictionary so that I could simply give myDictionary a key and it will invoke the correspondent method?
Here is what I have done up till now:
Dictionary<Message, Action> MessageAction = new Dictionary<Message, Action>()
{
{ myEnum.element1, method1 }
{ myEnum.element2, method2 }
};
public void method1()
{
// Logic for myEnum element 1
}
public void method2()
{
// Logic for myEnum element 2
}
|