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

◆ HandleAttributeColumn()

void System.Data.XSDSchema.HandleAttributeColumn ( XmlSchemaAttribute attrib,
DataTable table,
bool isBase )
inlinepackage

Definition at line 1864 of file XSDSchema.cs.

1865 {
1866 Type type = null;
1869 string text = null;
1870 SimpleType simpleType = null;
1871 if (xmlSchemaAnnotated == null)
1872 {
1873 text = xmlSchemaAttribute.SchemaTypeName.Name;
1874 if (!string.IsNullOrEmpty(text))
1875 {
1876 type = ((!(xmlSchemaAttribute.SchemaTypeName.Namespace != "http://www.w3.org/2001/XMLSchema")) ? ParseDataType(xmlSchemaAttribute.SchemaTypeName.Name) : ParseDataType(xmlSchemaAttribute.SchemaTypeName.ToString()));
1877 }
1878 else
1879 {
1880 text = string.Empty;
1881 type = typeof(string);
1882 }
1883 }
1885 {
1887 simpleType = new SimpleType(xmlSchemaSimpleType);
1888 if (xmlSchemaSimpleType.QualifiedName.Name != null && xmlSchemaSimpleType.QualifiedName.Name.Length != 0 && xmlSchemaSimpleType.QualifiedName.Namespace != "http://www.w3.org/2001/XMLSchema")
1889 {
1890 text = xmlSchemaSimpleType.QualifiedName.ToString();
1891 type = ParseDataType(xmlSchemaSimpleType.QualifiedName.ToString());
1892 }
1893 else
1894 {
1895 type = ParseDataType(simpleType.BaseType);
1896 text = simpleType.Name;
1897 if (simpleType.Length == 1 && type == typeof(string))
1898 {
1899 type = typeof(char);
1900 }
1901 }
1902 }
1903 else
1904 {
1906 {
1907 if (xmlSchemaAnnotated.Id == null)
1908 {
1909 throw ExceptionBuilder.DatatypeNotDefined();
1910 }
1911 throw ExceptionBuilder.UndefinedDatatype(xmlSchemaAnnotated.Id);
1912 }
1913 text = ((XmlSchemaElement)xmlSchemaAnnotated).SchemaTypeName.Name;
1915 }
1917 bool flag = true;
1918 DataColumn dataColumn;
1919 if ((!isBase || FromInference) && table.Columns.Contains(text2, caseSensitive: true))
1920 {
1921 dataColumn = table.Columns[text2];
1922 flag = false;
1923 if (FromInference)
1924 {
1925 if (dataColumn.ColumnMapping != MappingType.Attribute)
1926 {
1927 throw ExceptionBuilder.ColumnTypeConflict(dataColumn.ColumnName);
1928 }
1929 if ((string.IsNullOrEmpty(attrib.QualifiedName.Namespace) && string.IsNullOrEmpty(dataColumn._columnUri)) || string.Equals(attrib.QualifiedName.Namespace, dataColumn.Namespace, StringComparison.Ordinal))
1930 {
1931 return;
1932 }
1933 dataColumn = new DataColumn(text2, type, null, MappingType.Attribute);
1934 flag = true;
1935 }
1936 }
1937 else
1938 {
1939 dataColumn = new DataColumn(text2, type, null, MappingType.Attribute);
1940 }
1941 SetProperties(dataColumn, xmlSchemaAttribute.UnhandledAttributes);
1943 SetExtProperties(dataColumn, xmlSchemaAttribute.UnhandledAttributes);
1944 if (dataColumn.Expression != null && dataColumn.Expression.Length != 0)
1945 {
1947 }
1948 if (simpleType != null && simpleType.Name != null && simpleType.Name.Length > 0)
1949 {
1950 if (GetMsdataAttribute(xmlSchemaAnnotated, "targetNamespace") != null)
1951 {
1952 dataColumn.XmlDataType = simpleType.SimpleTypeQualifiedName;
1953 }
1954 }
1955 else
1956 {
1958 }
1961 dataColumn.Namespace = attrib.QualifiedName.Namespace;
1962 dataColumn.Namespace = GetStringAttribute(attrib, "targetNamespace", dataColumn.Namespace);
1963 if (flag)
1964 {
1965 if (FromInference)
1966 {
1969 }
1970 table.Columns.Add(dataColumn);
1971 }
1972 if (attrib.Use == XmlSchemaUse.Prohibited)
1973 {
1974 dataColumn.ColumnMapping = MappingType.Hidden;
1976 string msdataAttribute = GetMsdataAttribute(xmlSchemaAttribute, "DefaultValue");
1977 if (msdataAttribute != null)
1978 {
1979 try
1980 {
1982 }
1983 catch (FormatException)
1984 {
1985 throw ExceptionBuilder.CannotConvert(msdataAttribute, type.FullName);
1986 }
1987 }
1988 }
1989 string text3 = ((attrib.Use == XmlSchemaUse.Required) ? GetMsdataAttribute(xmlSchemaAttribute, "DefaultValue") : xmlSchemaAttribute.DefaultValue);
1990 if (xmlSchemaAttribute.Use == XmlSchemaUse.Optional && text3 == null)
1991 {
1992 text3 = xmlSchemaAttribute.FixedValue;
1993 }
1994 if (text3 != null)
1995 {
1996 try
1997 {
1998 dataColumn.DefaultValue = dataColumn.ConvertXmlToObject(text3);
1999 }
2000 catch (FormatException)
2001 {
2002 throw ExceptionBuilder.CannotConvert(text3, type.FullName);
2003 }
2004 }
2005 }
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)
static string GetMsdataAttribute(XmlSchemaAnnotated node, string ln)
Definition XSDSchema.cs:342
string GetPrefix(string ns)
static void SetProperties(object instance, XmlAttribute[] attrs)
Definition XSDSchema.cs:217
bool GetBooleanAttribute(XmlSchemaAnnotated element, string attrName, bool defVal)
XmlSchemaAnnotated FindTypeNode(XmlSchemaAnnotated node)
Hashtable _attributes
Definition XSDSchema.cs:53
static ? string DecodeName(string? name)
Definition XmlConvert.cs:55

References System.Data.XSDSchema._attributes, System.Data.XSDSchema._columnExpressions, System.Data.DataColumnCollection.Add(), System.Collections.ArrayList.Add(), System.Data.ExceptionBuilder.CannotConvert(), System.Data.DataTable.Columns, System.Data.ExceptionBuilder.ColumnTypeConflict(), System.Data.DataColumnCollection.Contains(), System.Data.ExceptionBuilder.DatatypeNotDefined(), System.Xml.XmlConvert.DecodeName(), System.Xml.Dictionary, System.Data.XSDSchema.FindTypeNode(), System.Data.XSDSchema.FromInference, System.Data.XSDSchema.GetBooleanAttribute(), System.Data.XSDSchema.GetInstanceName(), System.Data.XSDSchema.GetMsdataAttribute(), System.Data.XSDSchema.GetPrefix(), System.Data.XSDSchema.GetStringAttribute(), System.Data.XSDSchema.HandleColumnExpression(), System.Data.XSDSchema.ParseDataType(), System.Data.XSDSchema.SetExtProperties(), System.Data.XSDSchema.SetProperties(), System.text, System.type, and System.Data.ExceptionBuilder.UndefinedDatatype().

Referenced by System.Data.XSDSchema.HandleAttributeGroup(), and System.Data.XSDSchema.HandleAttributes().