public void WriteXmlSchema(XmlWriter writer, bool writeHierarchy)
{
IntPtr hscp;
Bid.ScopeEnter(out hscp, "<ds.DataTable.WriteXmlSchema|API> %d#\n", ObjectID);
try{
if (this.tableName.Length == 0) {
throw ExceptionBuilder.CanNotSerializeDataTableWithEmptyName();
}
if (!CheckForClosureOnExpressions(this, writeHierarchy)) {
throw ExceptionBuilder.CanNotSerializeDataTableHierarchy();
}
DataSet ds = null;
string tablenamespace = this.tableNamespace;//SQL BU Defect Tracking 286968
// Generate SchemaTree and write it out
if (null == this.DataSet) {
ds = new DataSet();
// if user set values on DataTable, it isn't necessary
// to set them on the DataSet because they won't be inherited
// but it is simpler to set them in both places
// if user did not set values on DataTable, it is required
// to set them on the DataSet so the table will inherit
// the value already on the Datatable
ds.SetLocaleValue(_culture, _cultureUserSet);
ds.CaseSensitive = this.CaseSensitive;
ds.Namespace = this.Namespace;
ds.RemotingFormat = this.RemotingFormat;
ds.Tables.Add(this);
}
if (writer != null) {
XmlTreeGen treeGen = new XmlTreeGen(SchemaFormat.Public);
treeGen.Save(null, this, writer, writeHierarchy);
}
if (null != ds) {
ds.Tables.Remove(this);
this.tableNamespace = tablenamespace;
}
}
finally {
Bid.ScopeLeave(ref hscp);
}
}