public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { var ee = new ConditionDeserializer(); var obj = JObject.Load(reader); return(Choice.GetBuilder().Transition(NextStateTransition.GetBuilder() .NextStateName(obj[PropertyNames.NEXT] .Value <string>())) .Condition(ee.DeserializeCondition(obj))); }
public NextMachineState GetNext(Token token) { NextMachineState nextState = this.CurrentState; NextStateTransition transition = new NextStateTransition(CurrentState, token.Type); if (!transitions.TryGetValue(transition, out nextState)) { throw new Exception("NEXT: Invalid transition: " + CurrentState + " -> " + nextState + "\n" + token.Text + " " + token.Type); } if (nextState == NextMachineState.VAR) { this.command.AddStepToLoopVariableAndLoopBack(token); } Console.WriteLine("NEXT: " + this.CurrentState + " -> " + nextState + ": " + token.Text); return(nextState); }
/** * A transition to another state in the state machine. * * @param nextStateName Name of state to transition to. * @return Transition to another state in the state machine. * @see <a href="https://states-language.net/spec.html#transition">https://states-language.net/spec.html#transition</a> */ public static NextStateTransition.Builder Next(string nextStateName) { return(NextStateTransition.GetBuilder().NextStateName(nextStateName)); }
public override bool Equals(object obj) { NextStateTransition other = obj as NextStateTransition; return(other != null && this.CurrentState == other.CurrentState && this.Token == other.Token); }