System.Data.XmlSchemaDataImporter.ImportColumnAttribute C# (CSharp) Method

ImportColumnAttribute() private method

private ImportColumnAttribute ( XmlSchemaAttribute attr ) : void
attr System.Xml.Schema.XmlSchemaAttribute
return void
		private void ImportColumnAttribute (XmlSchemaAttribute attr)
		{
			DataColumn col = new DataColumn ();
			col.ColumnName = attr.QualifiedName.Name;
			col.Namespace = attr.QualifiedName.Namespace;
			XmlSchemaDatatype dt = null;
#if NET_2_0
			dt = GetSchemaPrimitiveType (((XmlSchemaSimpleType) attr.AttributeSchemaType).Datatype);
#else
			dt = GetSchemaPrimitiveType (attr.AttributeType);
#endif
			// This complicated check comes from the fact that
			// MS.NET fails to map System.Object to anyType (that
			// will cause ReadTypedObject() fail on XmlValidatingReader).
			// ONLY In DataSet context, we set System.String for
			// simple ur-type.
			col.DataType = ConvertDatatype (dt);
			if (col.DataType == typeof (object))
				col.DataType = typeof (string);
			// When attribute use="prohibited", then it is regarded as 
			// Hidden column.
			if (attr.Use == XmlSchemaUse.Prohibited)
				col.ColumnMapping = MappingType.Hidden;
			else {
				col.ColumnMapping = MappingType.Attribute;
				col.DefaultValue = GetAttributeDefaultValue (attr);
			}
			if (attr.Use == XmlSchemaUse.Required)
				col.AllowDBNull = false;

#if NET_2_0
			FillFacet (col, attr.AttributeSchemaType as XmlSchemaSimpleType);
#else
			FillFacet (col, attr.AttributeType as XmlSchemaSimpleType);
#endif

			// Call this method after filling the name
			ImportColumnMetaInfo (attr, attr.QualifiedName, col);
			AddColumn (col);
		}