So for example a List containing 5 Action<T>
s A, B, C, D, and E where B calls A or C at some point within its own "Actioning".
Obviously I could do something like this (please do not get distracted by the uselessness of this example):
public static List<Action<string>> ActionList = new List<Action<string>>
{
inputString => //print reverse of string
{
Console.WriteLine(inputString.Reverse());
},
inputString => //print reverse of string if "Cat" otherwise print the string twice
{
if (inputString.Equals("Cat"))
{
ActionList[0](inputString);
}
else
{
ActionList[2](inputString);
}
},
inputString => //print the string twice
{
Console.WriteLine(inputString);
Console.WriteLine(inputString);
},
inputString => //print the string in uppercase
{
Console.WriteLine(inputString.ToUpper());
},
inputString => //print the string in lowercase
{
Console.WriteLine(inputString.ToLower());
},
};
The real thing would contain hundreds of Actions, each far more complex, many calling 10s of other Actions in different ways inside switch statements, etc.
I preferably want to have each Action wrapped into their own static class so I can keep all the code relevant to making that Action work that I've written in that class too, perhaps even some extra properties too. But of course that's still a pain because I still have to hardcode the List and add elements every time I add a new Action and even though I can make a common interface for each wrapper to implement, I cannot make it static (I understand why interfaces can't be static) despite only ever needing "static behaviour" which is an immediate red flag.
Anyone know a good way to do this?