是否有一种设计模式可以应用于我可以构建复杂的工作流程而无需编写多个条件和嵌套条件语句 - 我认为答案可能在于采用规范模式之类的东西,但不确定它是如何在 C# 中组合在一起的?
static void Main()
{
// I have some predicates
bool transientError = true;
bool fatalError = true;
bool maxRetriesReached = true;
// I have some actions
Action SendToDeadletter = () => { };
Action Retry = () => { };
Action Complete = () => { };
// Is there a way of building the following without using conditional statements
// something like Specification Pattern?
// maxRetriesReached || fatalError => SendToDeadletter()
// transientError && !maxRetriesReached => Retry()
// !transientError && !fatalError => Complete()
}