Exemplo n.º 1
0
        public Bug(string title)
        {
            _title = title;

            var _machine = StateMachine<State, Trigger>.Create(() => _state, s => _state = s);

            _assignTrigger = _machine.SetTriggerParameters<string>(Trigger.Assign);

            _machine.Configure(State.Open)
                .Permit(Trigger.Assign, State.Assigned);

            _machine.Configure(State.Assigned)
                .SubstateOf(State.Open)
                .OnEntryFrom(_assignTrigger, assignee => OnAssigned(assignee))
                .PermitReentry(Trigger.Assign)
                .Permit(Trigger.Close, State.Closed)
                .Permit(Trigger.Defer, State.Deferred)
                .OnExit(() => OnDeassigned());

            _machine.Configure(State.Deferred)
                .OnEntry(() => _assignee = null)
                .Permit(Trigger.Assign, State.Assigned);

            this._machine = _machine.FinishConfiguration();
        }
Exemplo n.º 2
0
 static void Print(IConfiguredStatemachine<State, Trigger> phoneCall)
 {
     Console.WriteLine("[Status:] {0}", phoneCall);
 }
Exemplo n.º 3
0
 static void Fire(IConfiguredStatemachine<State, Trigger> phoneCall, Trigger trigger)
 {
     Console.WriteLine("[Firing:] {0}", trigger);
     phoneCall.Fire(trigger);
 }