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

◆ HandleElementColumn()

void System.Data.XSDSchema.HandleElementColumn ( XmlSchemaElement elem,
DataTable table,
bool isBase )
inlinepackage

Definition at line 2008 of file XSDSchema.cs.

2009 {
2010 Type type = null;
2012 if (xmlSchemaElement == null)
2013 {
2014 return;
2015 }
2017 string text = null;
2018 SimpleType simpleType = null;
2019 if (xmlSchemaAnnotated == null)
2020 {
2021 text = xmlSchemaElement.SchemaTypeName.Name;
2022 if (string.IsNullOrEmpty(text))
2023 {
2024 text = string.Empty;
2025 type = typeof(string);
2026 }
2027 else
2028 {
2029 type = ParseDataType(xmlSchemaElement.SchemaTypeName.Name);
2030 }
2031 }
2033 {
2035 simpleType = new SimpleType(node);
2036 if (((XmlSchemaSimpleType)xmlSchemaAnnotated).Name != null && ((XmlSchemaSimpleType)xmlSchemaAnnotated).Name.Length != 0 && ((XmlSchemaSimpleType)xmlSchemaAnnotated).QualifiedName.Namespace != "http://www.w3.org/2001/XMLSchema")
2037 {
2038 text = ((XmlSchemaSimpleType)xmlSchemaAnnotated).QualifiedName.ToString();
2040 }
2041 else
2042 {
2043 for (node = ((simpleType.XmlBaseType != null && simpleType.XmlBaseType.Namespace != "http://www.w3.org/2001/XMLSchema") ? (_schemaTypes[simpleType.XmlBaseType] as XmlSchemaSimpleType) : null); node != null; node = ((simpleType.XmlBaseType != null && simpleType.XmlBaseType.Namespace != "http://www.w3.org/2001/XMLSchema") ? (_schemaTypes[simpleType.XmlBaseType] as XmlSchemaSimpleType) : null))
2044 {
2045 simpleType.LoadTypeValues(node);
2046 }
2047 type = ParseDataType(simpleType.BaseType);
2048 text = simpleType.Name;
2049 if (simpleType.Length == 1 && type == typeof(string))
2050 {
2051 type = typeof(char);
2052 }
2053 }
2054 }
2056 {
2057 text = ((XmlSchemaElement)xmlSchemaAnnotated).SchemaTypeName.Name;
2059 }
2060 else
2061 {
2063 {
2064 if (xmlSchemaAnnotated.Id == null)
2065 {
2066 throw ExceptionBuilder.DatatypeNotDefined();
2067 }
2068 throw ExceptionBuilder.UndefinedDatatype(xmlSchemaAnnotated.Id);
2069 }
2070 if (string.IsNullOrEmpty(GetMsdataAttribute(elem, "DataType")))
2071 {
2072 throw ExceptionBuilder.DatatypeNotDefined();
2073 }
2074 type = typeof(object);
2075 }
2077 bool flag = true;
2078 DataColumn dataColumn;
2079 if ((!isBase || FromInference) && table.Columns.Contains(text2, caseSensitive: true))
2080 {
2081 dataColumn = table.Columns[text2];
2082 flag = false;
2083 if (FromInference)
2084 {
2085 if (dataColumn.ColumnMapping != MappingType.Element)
2086 {
2087 throw ExceptionBuilder.ColumnTypeConflict(dataColumn.ColumnName);
2088 }
2089 if ((string.IsNullOrEmpty(elem.QualifiedName.Namespace) && string.IsNullOrEmpty(dataColumn._columnUri)) || string.Equals(elem.QualifiedName.Namespace, dataColumn.Namespace, StringComparison.Ordinal))
2090 {
2091 return;
2092 }
2093 dataColumn = new DataColumn(text2, type, null, MappingType.Element);
2094 flag = true;
2095 }
2096 }
2097 else
2098 {
2099 dataColumn = new DataColumn(text2, type, null, MappingType.Element);
2100 }
2101 SetProperties(dataColumn, xmlSchemaElement.UnhandledAttributes);
2103 SetExtProperties(dataColumn, xmlSchemaElement.UnhandledAttributes);
2104 if (!string.IsNullOrEmpty(dataColumn.Expression))
2105 {
2107 }
2108 if (simpleType != null && simpleType.Name != null && simpleType.Name.Length > 0)
2109 {
2110 if (GetMsdataAttribute(xmlSchemaAnnotated, "targetNamespace") != null)
2111 {
2112 dataColumn.XmlDataType = simpleType.SimpleTypeQualifiedName;
2113 }
2114 }
2115 else
2116 {
2118 }
2121 if (!elem.RefName.IsEmpty || elem.QualifiedName.Namespace != table.Namespace)
2122 {
2123 dataColumn.Namespace = elem.QualifiedName.Namespace;
2124 dataColumn.Namespace = GetStringAttribute(xmlSchemaElement, "targetNamespace", dataColumn.Namespace);
2125 }
2126 else if (elem.Form == XmlSchemaForm.Unqualified)
2127 {
2128 dataColumn.Namespace = string.Empty;
2129 }
2130 else if (elem.Form == XmlSchemaForm.None)
2131 {
2132 XmlSchemaObject parent = elem.Parent;
2133 while (parent.Parent != null)
2134 {
2135 parent = parent.Parent;
2136 }
2137 if (((XmlSchema)parent).ElementFormDefault == XmlSchemaForm.Unqualified)
2138 {
2139 dataColumn.Namespace = string.Empty;
2140 }
2141 }
2142 else
2143 {
2144 dataColumn.Namespace = elem.QualifiedName.Namespace;
2145 dataColumn.Namespace = GetStringAttribute(xmlSchemaElement, "targetNamespace", dataColumn.Namespace);
2146 }
2148 int num = (int)Convert.ChangeType(stringAttribute, typeof(int), null);
2149 if (flag)
2150 {
2151 if (num > -1 && num < table.Columns.Count)
2152 {
2153 table.Columns.AddAt(num, dataColumn);
2154 }
2155 else
2156 {
2157 table.Columns.Add(dataColumn);
2158 }
2159 }
2160 if (dataColumn.Namespace == table.Namespace)
2161 {
2162 dataColumn._columnUri = null;
2163 }
2164 if (FromInference)
2165 {
2167 }
2168 string defaultValue = xmlSchemaElement.DefaultValue;
2169 if (defaultValue == null)
2170 {
2171 return;
2172 }
2173 try
2174 {
2175 dataColumn.DefaultValue = dataColumn.ConvertXmlToObject(defaultValue);
2176 }
2177 catch (FormatException)
2178 {
2179 throw ExceptionBuilder.CannotConvert(defaultValue, type.FullName);
2180 }
2181 }
virtual int Add(object? value)
string GetInstanceName(XmlSchemaAnnotated node)
string GetStringAttribute(XmlSchemaAnnotated element, string attrName, string defVal)
void HandleColumnExpression(object instance, XmlAttribute[] attrs)
Definition XSDSchema.cs:321
static void SetExtProperties(object instance, XmlAttribute[] attrs)
Definition XSDSchema.cs:282
ArrayList _columnExpressions
Definition XSDSchema.cs:41
Type ParseDataType(string dt)
Hashtable _schemaTypes
Definition XSDSchema.cs:59
static string GetMsdataAttribute(XmlSchemaAnnotated node, string ln)
Definition XSDSchema.cs:342
Hashtable _elementsTable
Definition XSDSchema.cs:55
string GetPrefix(string ns)
static void SetProperties(object instance, XmlAttribute[] attrs)
Definition XSDSchema.cs:217
XmlSchemaAnnotated FindTypeNode(XmlSchemaAnnotated node)
static CultureInfo CurrentCulture
static ? string DecodeName(string? name)
Definition XmlConvert.cs:55

References System.Data.XSDSchema._columnExpressions, System.Data.XSDSchema._elementsTable, System.Data.XSDSchema._schemaTypes, System.Data.DataColumnCollection.Add(), System.Collections.ArrayList.Add(), System.Data.DataColumnCollection.AddAt(), System.Data.ExceptionBuilder.CannotConvert(), System.Convert.ChangeType(), System.Data.DataTable.Columns, System.Data.ExceptionBuilder.ColumnTypeConflict(), System.Data.DataColumnCollection.Contains(), System.Data.InternalDataCollectionBase.Count, System.Globalization.CultureInfo.CurrentCulture, System.Data.ExceptionBuilder.DatatypeNotDefined(), System.Xml.XmlConvert.DecodeName(), System.Xml.Dictionary, System.Data.XSDSchema.FindTypeNode(), System.Data.XSDSchema.FromInference, System.Data.XSDSchema.GetInstanceName(), System.Data.XSDSchema.GetMsdataAttribute(), System.Data.XSDSchema.GetPrefix(), System.Data.XSDSchema.GetStringAttribute(), System.Data.XSDSchema.HandleColumnExpression(), System.Data.Name, System.Data.DataTable.Namespace, System.Xml.Schema.XmlSchemaObject.Parent, System.Data.XSDSchema.ParseDataType(), System.Data.XSDSchema.SetExtProperties(), System.Data.XSDSchema.SetProperties(), System.text, System.ToString, System.type, and System.Data.ExceptionBuilder.UndefinedDatatype().

Referenced by System.Data.XSDSchema.HandleParticle().