Well, you have not provide enough code for use to have enough information to give the best solutions so any solution would be a guess... But in any case, I would make many changes to that design.
Names are not all properly selected but I don't have necessary information about what the application does
enum Age { Low = 0, Medium = 1, High = 2}
enum AgeType { Low = 0, Medium = 1, High = 2}
enum Payment { Low = 0, Medium = 1, High = 2}
enum Country { US = 0, Canada = 1, Mexico = 2}
enum Working{ Low = 0, Medium = 1, High = 2}
class Data
{
public Age { get; set; }
public AgeType { get; set; }
public Payment { get; set; }
public Country { get; set; }
public Working { get; set; }
}
class Code
{
public abstract bool Test(Data data);
public abstract void Execute(Data data);
}
class Case1Code : Code
{
public virtual bool Test(Data data)
{
return data.Age == Age.Low && ... ;
}
public virtual void Execute(Data data)
{
}
}
class Factory
{
static Factory()
{
allChoices = new List<Code>();
allChoices.Add(new Case1Code());
allChoices.Add ... ;
}
public void Process(Data data)
{
allChoices.FirstOrDefault(x => x.Test(data))?.Process(data);
}
private static List<Code> allChoices;
}
This would be particularly useful if there are many operations that could depend on a condition set. If some classes have similar code, then you can have some protected methods for code sharing purpose.
In practice, you might want to have class hierarchies for part of the data (say the country) and then forward to another class hierarchies (maybe for age groups). However, without knowing exactly the business processus, it is hard to find the best solution.
For example, the country class might define the age limits for a given group or the available working status. Many countries might share similar rules so they would probably use the same class.
Depending on the problem, you might prefer to use
Action<>
or
Func<>
instead particularly if you have only one simple operation or if each operation have its own conditions...