private static void ReadExpected(Type1Tokenizer tokenizer, Type1Token.TokenType type, string text = null) { var token = tokenizer.GetNext(); if (token == null) { throw new InvalidOperationException($"Type 1 Encrypted portion ended when a token with text '{text}' was expected."); } if (token.Type != type || (text != null && !string.Equals(token.Text, text, StringComparison.OrdinalIgnoreCase))) { throw new InvalidOperationException($"Found invalid token {token} when type {type} with text {text} was expected."); } }
private static void ReadExpectedAfterOptional(Type1Tokenizer tokenizer, Type1Token.TokenType optionalType, string optionalText, Type1Token.TokenType type, string text) { var token = tokenizer.GetNext(); if (token == null) { throw new InvalidOperationException($"Type 1 Encrypted portion ended when a token with text '{optionalText}' or '{text}' was expected."); } if (token.Type == type && string.Equals(token.Text, text, StringComparison.OrdinalIgnoreCase)) { return; } if (token.Type == optionalType && string.Equals(token.Text, optionalText, StringComparison.OrdinalIgnoreCase)) { ReadExpected(tokenizer, type, text); return; } throw new InvalidOperationException($"Found invalid token {token} when type {type} with text {text} was expected."); }