private TableSchemaInfo AddTableSchema(XmlNameTable nameTable, DataTable table)
{
// Enzol:This is the opposite of the previous function:
// we populate the nametable so that the hash comparison can happen as
// object comparison instead of strings.
// Sdub: GetIdentity is called from two places: BuildIdentityMap() and LoadRows()
// First case deals with decoded names; Second one with encoded names.
// We decided encoded names in first case (instead of decoding them in second)
// because it save us time in LoadRows(). We have, as usual, more data them schemas
string _tableLocalName = table.EncodedTableName; // Table name
string tableLocalName = nameTable.Get(_tableLocalName); // Look it up in nametable
if (tableLocalName == null)
{ // If not found
tableLocalName = nameTable.Add(_tableLocalName); // Add it
}
table._encodedTableName = tableLocalName; // And set it back
string tableNamespace = nameTable.Get(table.Namespace); // Look ip table namespace
if (tableNamespace == null)
{ // If not found
tableNamespace = nameTable.Add(table.Namespace); // Add it
}
else
{
if (table._tableNamespace != null) // Update table namespace
table._tableNamespace = tableNamespace;
}
TableSchemaInfo tableSchemaInfo = new TableSchemaInfo(table);
// Create new table schema info
_tableSchemaMap[new XmlNodeIdentety(tableLocalName, tableNamespace)] = tableSchemaInfo;
// And add it to the hashtable
return tableSchemaInfo; // Return it as we have to populate
// Column schema map and Child table
// schema map in it
}