System.Xml.Serialization.XmlReflectionImporter.CheckContext C# (CSharp) Method

CheckContext() private method

private CheckContext ( TypeDesc typeDesc, ImportContext context ) : void
typeDesc TypeDesc
context ImportContext
return void
        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);
        }