internal void HandleSimpleContentColumn(string strType, DataTable table, bool isBase, XmlAttribute[] attrs, bool isNillable)
{
// for Named Simple type support : We should not recieved anything here other than string.
// there can not be typed simple content
// disallow multiple simple content columns for the table
if (FromInference && table.XmlText != null) // backward compatability for inference
return;
Type type = null;
if (strType == null)
{
return;
}
type = ParseDataType(strType); // we pass it correctly when we call the method, no need to special check.
DataColumn column;
string colName;
if (FromInference)
{
int i = 0;
colName = table.TableName + "_Text";
while (table.Columns[colName] != null)
{
colName = colName + i++;
}
}
else
colName = table.TableName + "_text";
string columnName = colName;
bool isToAdd = true;
if ((!isBase) && (table.Columns.Contains(columnName, true)))
{
column = table.Columns[columnName];
isToAdd = false;
}
else
{
column = new DataColumn(columnName, type, null, MappingType.SimpleContent);
}
SetProperties(column, attrs);
HandleColumnExpression(column, attrs);
SetExtProperties(column, attrs);
string tmp = (-1).ToString(CultureInfo.CurrentCulture);
string defValue = null;
//try to see if attributes contain allownull
column.AllowDBNull = isNillable;
if (attrs != null)
for (int i = 0; i < attrs.Length; i++)
{
if (attrs[i].LocalName == Keywords.MSD_ALLOWDBNULL && attrs[i].NamespaceURI == Keywords.MSDNS)
if (attrs[i].Value == Keywords.FALSE)
column.AllowDBNull = false;
if (attrs[i].LocalName == Keywords.MSD_ORDINAL && attrs[i].NamespaceURI == Keywords.MSDNS)
tmp = attrs[i].Value;
if (attrs[i].LocalName == Keywords.MSD_DEFAULTVALUE && attrs[i].NamespaceURI == Keywords.MSDNS)
defValue = attrs[i].Value;
}
int ordinal = (int)Convert.ChangeType(tmp, typeof(int), null);
//SetExtProperties(column, attr.UnhandledAttributes);
if ((column.Expression != null) && (column.Expression.Length != 0))
{
_columnExpressions.Add(column);
}
column.XmlDataType = strType;
column.SimpleType = null;
//column.Namespace = typeNode.SourceUri;
if (FromInference)
column.Prefix = GetPrefix(column.Namespace);
if (isToAdd)
{
if (FromInference) // move this setting to SetProperties
column.AllowDBNull = true;
if (ordinal > -1 && ordinal < table.Columns.Count)
table.Columns.AddAt(ordinal, column);
else
table.Columns.Add(column);
}
if (defValue != null)
try
{
column.DefaultValue = column.ConvertXmlToObject(defValue);
}
catch (System.FormatException)
{
throw ExceptionBuilder.CannotConvert(defValue, type.FullName);
}
}