I've been toying around with various ideas in code, and I've come to the conclusion that the following formula is true:
Lambda Expressions + Func<> and Action<> = Easy Command Patterns
As a very contrived, quick example:
public class DoStuff
{
private Func<CommandResult> Step1 { get; set; }
private Func<CommandResult> Step2 { get; set; }
public DoStuff(Func<CommandResult> step1, Func<CommandResult> step2)
Step1 = step1;
Step2 = step2;
}
public void DoTheStuffProcessing()
CommandResult result = step1();
if (result.Succeeded)
step2();
It's ... so ... beautiful ...
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.