private void ThrowOnError(TokenObject t) { if (t is TokenError) { throw new ApplicationException(t.ToString()); } }
private void ThrowOnEmptyOrError(TokenObject t) { if (t is TokenError) { throw new ApplicationException(t.ToString()); } else if (t is TokenEmpty) { throw new ApplicationException("Unexpected end of PDF document."); } }
private T ThrowIfNot <T>(TokenObject t) where T : TokenObject { if (t is TokenError) { throw new ApplicationException(t.ToString()); } else if (t is TokenEmpty) { throw new ApplicationException("Unexpected end of PDF document."); } else if (!(t is T)) { throw new ApplicationException($"Found {t.GetType().Name} instead of {typeof(T).Name}."); } return((T)t); }