Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ImportEnumeratedDataType()

TypeMapping System.Xml.Serialization.XmlSchemaImporter.ImportEnumeratedDataType ( XmlSchemaSimpleType dataType,
string typeNs,
string identifier,
TypeFlags flags,
bool isList )
inlineprivate

Definition at line 1760 of file XmlSchemaImporter.cs.

1761 {
1762 TypeMapping typeMapping = (TypeMapping)base.ImportedMappings[dataType];
1763 if (typeMapping != null)
1764 {
1765 return typeMapping;
1766 }
1767 XmlSchemaType xmlSchemaType = dataType;
1768 while (!xmlSchemaType.DerivedFrom.IsEmpty)
1769 {
1770 xmlSchemaType = FindType(xmlSchemaType.DerivedFrom, (TypeFlags)40);
1771 }
1773 {
1774 return null;
1775 }
1776 TypeDesc typeDesc = base.Scope.GetTypeDesc((XmlSchemaSimpleType)xmlSchemaType);
1777 if (typeDesc != null && typeDesc.FullName != typeof(string).FullName)
1778 {
1779 return ImportPrimitiveDataType(dataType, flags);
1780 }
1781 identifier = Accessor.UnescapeName(identifier);
1783 EnumMapping enumMapping = new EnumMapping();
1784 enumMapping.IsReference = base.Schemas.IsReference(dataType);
1785 enumMapping.TypeDesc = new TypeDesc(text, text, TypeKind.Enum, null, TypeFlags.None);
1786 if (dataType.Name != null && dataType.Name.Length > 0)
1787 {
1789 }
1790 enumMapping.Namespace = typeNs;
1792 CodeIdentifiers codeIdentifiers = new CodeIdentifiers();
1793 XmlSchemaSimpleTypeContent content = dataType.Content;
1795 {
1797 for (int i = 0; i < xmlSchemaSimpleTypeRestriction.Facets.Count; i++)
1798 {
1799 object obj = xmlSchemaSimpleTypeRestriction.Facets[i];
1801 {
1803 if (typeDesc != null && typeDesc.HasCustomFormatter)
1804 {
1805 XmlCustomFormatter.ToDefaultValue(xmlSchemaEnumerationFacet.Value, typeDesc.FormatterName);
1806 }
1807 ConstantMapping constantMapping = new ConstantMapping();
1808 string identifier2 = CodeIdentifier.MakeValid(xmlSchemaEnumerationFacet.Value);
1812 }
1813 }
1814 }
1815 enumMapping.Constants = (ConstantMapping[])codeIdentifiers.ToArray(typeof(ConstantMapping));
1816 if (isList && enumMapping.Constants.Length > 63)
1817 {
1818 typeMapping = GetDefaultMapping((TypeFlags)56);
1819 base.ImportedMappings.Add(dataType, typeMapping);
1820 return typeMapping;
1821 }
1822 base.ImportedMappings.Add(dataType, enumMapping);
1823 base.Scope.AddTypeMapping(enumMapping);
1824 return enumMapping;
1825 }
void Add(TKey key, TValue value)
TypeMapping GetDefaultMapping(TypeFlags flags)
XmlSchemaType FindType(XmlQualifiedName name, TypeFlags flags)
string GenerateUniqueTypeName(string desiredName, string ns)
PrimitiveMapping ImportPrimitiveDataType(XmlSchemaSimpleType dataType, TypeFlags flags)

References System.Collections.Generic.Dictionary< TKey, TValue >.Add(), System.Xml.Schema.XmlSchemaSimpleType.Content, System.Collections.Generic.Dictionary< TKey, TValue >.Count, System.Xml.Dictionary, System.Xml.Serialization.XmlSchemaImporter.FindType(), System.FullName, System.Xml.Serialization.XmlSchemaImporter.GenerateUniqueTypeName(), System.Xml.Serialization.XmlSchemaImporter.GetDefaultMapping(), System.Xml.Serialization.XmlSchemaImporter.ImportPrimitiveDataType(), System.Xml.Serialization.CodeIdentifier.MakeValid(), System.Xml.Schema.XmlSchemaType.Name, System.obj, System.text, System.Xml.Serialization.XmlCustomFormatter.ToDefaultValue(), and System.Xml.Serialization.Accessor.UnescapeName().

Referenced by System.Xml.Serialization.XmlSchemaImporter.ImportDataType().