I would suggest not to go for any Command factories. Command pattern actually lets you parameterize your request object. So you can create different type of command object for your easy and complex command scenario, and then you can execute them based on your command type you retrive from property file. This is what i would do following command pattern, see if it helps:
public interface IOperations
{
void PerformOperations();
}
public class EasyOperations : IOperations
{
public void PerformOperations()
{
Console.WriteLine("Do easy operations here");
}
}
public class ComplexOperations : IOperations
{
public void PerformOperations()
{
Console.WriteLine("Do complex operations here");
}
}
public interface ICommand
{
void Execute();
}
public class EasyCommand : ICommand
{
IOperations opn;
public EasyCommand(IOperations opn)
{
this.opn=opn;
}
public void Execute()
{
opn.PerformOperations();
}
}
public class ComplexCommand : ICommand
{
IOperations opn;
public ComplexCommand(IOperations opn)
{
this.opn=opn;
}
public void Execute()
{
opn.PerformOperations();
}
}
public class OperationsPerformer
{
IDictionary<string, ICommand> commands = new Dictionary<string, ICommand>();
public OperationsPerformer()
{
commands.Add("easy", new EasyCommand(new EasyOperations()));
commands.Add("complex",new ComplexCommand(new ComplexOperations()));
}
public void perform(string key)
{
if (commands[key] != null)
{
ICommand command = commands[key];
command.Execute();
}
}
}
public class Client
{
public static void Main(String[] args)
{
OperationsPerformer performer = new OperationsPerformer();
performer.perform("easy");
performer.perform("complex");
Console.ReadKey();
}
}
output:
Do easy operations here Do complex operations here