private void SerializeDataTable(SerializationInfo info, StreamingContext context, bool isSingleTable, SerializationFormat remotingFormat)
{
info.AddValue("DataTable.RemotingVersion", new Version(2, 0));
// SqlHotFix 299, SerializationFormat enumeration types don't exist in V1.1 SP1
if (SerializationFormat.Xml != remotingFormat)
{
info.AddValue("DataTable.RemotingFormat", remotingFormat);
}
if (remotingFormat != SerializationFormat.Xml)
{
//Binary
SerializeTableSchema(info, context, isSingleTable);
if (isSingleTable)
{
SerializeTableData(info, context, 0);
}
}
else
{
//XML/V1.0/V1.1
string tempDSNamespace = string.Empty;
bool fCreatedDataSet = false;
if (_dataSet == null)
{
DataSet ds = new DataSet("tmpDataSet");
// 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 = CaseSensitive;
ds._namespaceURI = Namespace;
Debug.Assert(ds.RemotingFormat == SerializationFormat.Xml, "RemotingFormat must be SerializationFormat.Xml");
ds.Tables.Add(this);
fCreatedDataSet = true;
}
else
{
tempDSNamespace = DataSet.Namespace;
DataSet._namespaceURI = Namespace;
}
info.AddValue(KEY_XMLSCHEMA, _dataSet.GetXmlSchemaForRemoting(this));
info.AddValue(KEY_XMLDIFFGRAM, _dataSet.GetRemotingDiffGram(this));
if (fCreatedDataSet)
{
_dataSet.Tables.Remove(this);
}
else
{
_dataSet._namespaceURI = tempDSNamespace;
}
}
}