thrownewArgumentException($"Unexpected type '{value?.GetType().Name}' encountered while reading '{objectDescription}'. The type '{nameof(BooleanToken)}' was expected.");
}
internalstaticNullTokenAssertNull(
thisTemplateTokenvalue,
stringobjectDescription)
{
if(valueisNullTokennullToken)
{
returnnullToken;
}
thrownewArgumentException($"Unexpected type '{value?.GetType().Name}' encountered while reading '{objectDescription}'. The type '{nameof(NullToken)}' was expected.");
}
internalstaticNumberTokenAssertNumber(
thisTemplateTokenvalue,
stringobjectDescription)
{
if(valueisNumberTokennumberToken)
{
returnnumberToken;
}
thrownewArgumentException($"Unexpected type '{value?.GetType().Name}' encountered while reading '{objectDescription}'. The type '{nameof(NumberToken)}' was expected.");
}
internalstaticStringTokenAssertString(
thisTemplateTokenvalue,
stringobjectDescription)
{
if(valueisStringTokenstringToken)
{
returnstringToken;
}
thrownewArgumentException($"Unexpected type '{value?.GetType().Name}' encountered while reading '{objectDescription}'. The type '{nameof(StringToken)}' was expected.");
}
internalstaticMappingTokenAssertMapping(
thisTemplateTokenvalue,
stringobjectDescription)
{
if(valueisMappingTokenmapping)
{
returnmapping;
}
thrownewArgumentException($"Unexpected type '{value?.GetType().Name}' encountered while reading '{objectDescription}'. The type '{nameof(MappingToken)}' was expected.");
}
internalstaticvoidAssertNotEmpty(
thisMappingTokenmapping,
stringobjectDescription)
{
if(mapping.Count==0)
{
thrownewArgumentException($"Unexpected empty mapping when reading '{objectDescription}'");
}
}
internalstaticScalarTokenAssertScalar(
thisTemplateTokenvalue,
stringobjectDescription)
{
if(valueisScalarTokenscalar)
{
returnscalar;
}
thrownewArgumentException($"Unexpected type '{value?.GetType().Name}' encountered while reading '{objectDescription}'. The type '{nameof(ScalarToken)}' was expected.");
}
internalstaticSequenceTokenAssertSequence(
thisTemplateTokenvalue,
stringobjectDescription)
{
if(valueisSequenceTokensequence)
{
returnsequence;
}
thrownewArgumentException($"Unexpected type '{value?.GetType().Name}' encountered while reading '{objectDescription}'. The type '{nameof(SequenceToken)}' was expected.");
}
internalstaticvoidAssertUnexpectedValue(
thisLiteralTokenliteral,
stringobjectDescription)
{
thrownewArgumentException($"Error while reading '{objectDescription}'. Unexpected value '{literal.ToString()}'");