private void RegisterToken() { JsonTokenType jsonTokenType = JsonTextReader.JsonTextToJsonTokenType(this.token.JsonTextTokenType); // Save the previous token before registering the new one JsonTokenType previousJsonTokenType = this.JsonObjectState.CurrentTokenType; // We register the token with the object state which should take care of all validity checks // but the separator check which we take care of below this.JsonObjectState.RegisterToken(jsonTokenType); switch (jsonTokenType) { case JsonTokenType.EndArray: if (this.hasSeperator) { throw new JsonUnexpectedEndArrayException(); } break; case JsonTokenType.EndObject: if (this.hasSeperator) { throw new JsonUnexpectedEndObjectException(); } break; default: switch (previousJsonTokenType) { case JsonTokenType.NotStarted: case JsonTokenType.BeginArray: case JsonTokenType.BeginObject: // No seperator is required after these tokens Debug.Assert(!this.hasSeperator, "Not valid to have a separator here!"); break; case JsonTokenType.FieldName: if (!this.hasSeperator) { throw new JsonMissingNameSeparatorException(); } break; default: if (!this.hasSeperator) { throw new JsonUnexpectedTokenException(); } break; } this.hasSeperator = false; break; } }