private DialoguePostcondition ParsePostcondition(JsonTextReader reader) { Dictionary <PostconditionOperators, string[]> postconditions = new Dictionary <PostconditionOperators, string[]>(); while (reader.Read()) { Spit(reader); if (reader.TokenType == JsonToken.PropertyName) { PostconditionOperators op = PostconditionOperatorMethods.FromString((string)reader.Value); reader.Read(); Spit(reader); if (reader.TokenType != JsonToken.StartArray) { throw new JsonReaderException("Unexpected element when parsing postcondition:" + reader.TokenType); } postconditions.Add(op, ParseConditionList(reader)); } else if (reader.TokenType == JsonToken.EndObject) { return(new DialoguePostcondition(postconditions)); } else { throw new JsonReaderException("Unexpected element when parsing postcondition: " + reader.TokenType); } } throw new JsonReaderException("Unexpected EOF when parsing preconditions"); }
public static void Update(this PostconditionOperators op, string operand, Conversation conversation) { switch (op) { case PostconditionOperators.SET_GLOBAL_FLAG: GlobalFlags.instance.Set(operand); break; case PostconditionOperators.UNSET_GLOBAL_FLAG: GlobalFlags.instance.Unset(operand); break; case PostconditionOperators.SET_CONVERSATION_FLAG: conversation.Set(operand); break; case PostconditionOperators.UNSET_CONVERSATION_FLAG: conversation.Unset(operand); break; default: throw new Exception("Fairly certain it's impossible to be here..."); } }