System.Xml.Serialization.XmlReflectionImporter.CheckContext C# (CSharp) Méthode

CheckContext() private méthode

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