void OnNodeChanged(XNode node, XObjectChangeEventArgs args) { switch (args.ObjectChange) { case XObjectChange.Add: _changes.OnNext(new XmlAddNodeChange(node.NodePath(), ImmutableXNode.Create(node))); break; case XObjectChange.Remove: XmlRemoveNodeChange change; if (!_pendingRemovalEvents.TryGetValue(node, out change)) { throw new InvalidOperationException("Element removed, but parent not found in "); } _changes.OnNext(change); break; default: throw new NotImplementedException(); } }
void OnNodeChanging(XNode node, XObjectChangeEventArgs args) { if (args.ObjectChange == XObjectChange.Remove) { // TODO May not want to actually emit the event before Changed has also run if (node.Parent == null) { throw new InvalidOperationException("Removed event only expected for non-root nodes"); } _pendingRemovalEvents[node] = new XmlRemoveNodeChange(node.NodePath(), ImmutableXNode.Create(node)); } }