I am implementing a set of C# classes /interfaces which should be reflect act as an action based on an input string. Basically, given an input string, the set of classes/ interfaces should identify the input and act as an action class.
I would like to use generics, whatever pattern that makes it comfortable to use.
Input examples:
1) ABC-{RandNumber(3)}
2) {CurrentNumber}
3) QWE-{RandString(5)}
4) ABY-{Date(yyyy)}
The interface represents an Action:
public interface IAction
{
}
The actions classes represents the contract actions
public abstract class Action: IAction
{
}
public sealed class RandonNumberAction : Action
{
}
public sealed class RandonStringAction : Action
{
}
Now here it comes the question. What’s the best approach to map the input string to the real concrete to action classes? Reflection? generics?