private void OnNodeInserted(object sender, XmlNodeChangedEventArgs args)
{
if (_ignoreXmlEvents)
return;
bool wasIgnoreDataSetEvents = _ignoreDataSetEvents;
bool wasIgnoreXmlEvents = _ignoreXmlEvents;
bool wasFoliationEnabled = IsFoliationEnabled;
_ignoreDataSetEvents = true;
_ignoreXmlEvents = true;
IsFoliationEnabled = false;
Debug.Assert(DataSet.EnforceConstraints == false);
bool fEnableCascading = DataSet._fEnableCascading;
DataSet._fEnableCascading = false;
try
{
// Handle both new node inserted and 2nd part of a move operation.
XmlNode node = args.Node;
XmlNode oldParent = args.OldParent;
XmlNode newParent = args.NewParent;
// The code bellow assumes a move operation is fired by DOM in 2 steps: a Remvoe followed by an Insert - this is the 2nd part, the Insert.
Debug.Assert(oldParent == null);
if (IsConnected(newParent))
{
// Inserting a node to connected tree
OnNodeInsertedInTree(node);
}
else
{
// Inserting a node to disconnected tree
OnNodeInsertedInFragment(node);
}
}
finally
{
_ignoreDataSetEvents = wasIgnoreDataSetEvents;
_ignoreXmlEvents = wasIgnoreXmlEvents;
IsFoliationEnabled = wasFoliationEnabled;
DataSet._fEnableCascading = fEnableCascading;
}
}