如何使用无状态守卫条款

时间:2017-11-01 23:45:27

标签: c# .net stateless-state-machine

我很擅长使用Stateless 并试图确保我理解保护条款的目的。我能够创建一个状态机,但我想基本上检查进入年龄> gt的状态。 12&&父权限存在。我是否正确理解了Guard子句,如果是这样,我将如何实现这样的条款?

    var stateMachine = new StateMachine<State, Trigger>(State.EnrollmentCompleted);

    stateMachine.Configure(State.EnrollmentCompleted)
                .Permit(Trigger.EnrollmentCompleted,ValidatingEnrollment, ***Guardclause to check if user age > 12 and Parentpermission=true***);

    return stateMachine;

1 个答案:

答案 0 :(得分:1)

GitHub page上有关于Guard子句的信息。基于此,看起来它只是......

stateMachine.Configure(State.EnrollmentCompleted)
            .Permit(Trigger.EnrollmentCompleted,ValidatingEnrollment, () => userAge > 12 && parentpermission);