private void CheckContext(TypeDesc typeDesc, ImportContext context)
{
switch (context)
{
case ImportContext.Element:
if (typeDesc.CanBeElementValue) return;
break;
case ImportContext.Attribute:
if (typeDesc.CanBeAttributeValue) return;
break;
case ImportContext.Text:
if (typeDesc.CanBeTextValue || typeDesc.IsEnum || typeDesc.IsPrimitive)
return;
break;
default:
throw new ArgumentException(SR.XmlInternalError, nameof(context));
}
throw UnsupportedException(typeDesc, context);
}