lundi 26 novembre 2018

design pattern to handle sequential tasks c#

i'm struggling to find a good way to create multiple workflows that sometimes share steps. are there any good resources that solves these problems, and enforces the "Required-Rule" between steps.

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; }
}

Aucun commentaire:

Enregistrer un commentaire