Skip to content

Instantly share code, notes, and snippets.

@chrisalexander
Created January 28, 2017 12:43
Show Gist options
  • Save chrisalexander/599feefee0c6e2519eaed42f61508b00 to your computer and use it in GitHub Desktop.
Save chrisalexander/599feefee0c6e2519eaed42f61508b00 to your computer and use it in GitHub Desktop.
interface ObjectProcessor4
{
bool CanProcess(DomainObject x, out Func<Result> doProcess);
}
public Result DoProcessing4(ObjectProcessor4 processor, DomainObject x)
{
Action doProcess;
if (processor.CanProcess(x, out doProcess))
{
// Here, the validation is done and we know it will work - unless the object has changed
return doProcess();
}
throw new InvalidOperationException("Validation failed, but we don't know why");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment