设计模式来处理顺序任务C#

时间:2018-11-26 09:51:02

标签: c# design-patterns

我正在努力寻找创建有时共享步骤的多个工作流的好方法。有什么好的资源可以解决这些问题,并在步骤之间强制执行“ Required-Rule”。

public class Weekday
{
    // Initial Step
    public BreakfastStep BreakfastStep { get; set; }

    // Breakfast step required
    public WorkStep WorkStep { get; set; }

    // Work step required
    public ExerciseStep ExerciseStep { get; set; }
}

public class Weekend
{
    // Initial Step
    public BreakfastStep BreakfastStep { get; set; }

    // Breakfast step required
    public ExerciseStep ExerciseStep { get; set; }
}

public class ExerciseStep
{
    public bool ChangeClothesComplete { get; set; }
    public bool RunEnabled => ChangeClothesComplete;
    public bool RunComplete { get; set; }
    public bool ShowerEnabled => RunComplete;
    public bool ShowerComplete { get; set; }
}

public class BreakfastStep
{
    public bool GetItemsComplete { get; set; }
    public bool MakeSandwichEnabled => GetItemsComplete;
    public bool MakeSandwichComplete { get; set; }
    public bool EatSandwichEnabled => MakeSandwichComplete;
    public bool EatSandwichComplete { get; set; }
}

public class WorkStep
{
    public bool CommuteComplete { get; set; }
    public bool DoWorkEnabled => CommuteComplete;
    public bool DoWorkComplete { get; set; }
    public bool CommuteBackHomeEnabled => DoWorkComplete;
    public bool CommuteBackHomeComplete { get; set; }
}

1 个答案:

答案 0 :(得分:1)

您应该看看状态设计模式。