How to get nodes from a relinking link

In a GoView’s DocumentChanged event handler, I want to do something when a link is deleted by the user.
The user can delete a link by pressing “Delete” key or dragging one of the two diamond handles in a link to nowhere.
In the second case, the FromNode and ToNode are null and the ports on the link are of type GoToolLinking.GoTemporaryPort, which is protected.
So the problem is how can I know the nodes a relinking link originally connected to in GoView’s DocumentChanged event handler.
In GoToolLinking.GoTemporaryPort, there is a Target property seeming useful to me, but because GoTemporaryPort is protected, I cannot access this property.

You can check the GoView.Tool, which if it is an instance of GoToolRelinking, will have the OriginalStartPort and the OriginalEndPort properties indicate the original ports. GoToolRelinking.Forwards will indicate which is which, if you care.
Of course that won’t help if the link was deleted programmatically, since only an interactive (unsuccessful) relinking operation will be using an instance of GoToolRelinking to delete the link. Perhaps implementing a GoView.SelectionDeleted event handler would be more appropriate than a GoDocument.Changed event handler, which is what GoView.DocumentChanged basically is.

In GoView.SelectionDeleted handler, the GoView.Selection is empty, so I’m trying using GoView.SelectionDeleting.

Oops, yes, you’re right about the Selection for the SelectionDeleted event.
Anyway, I assume you got the information you needed (and maybe more) by looking at the GoToolRelinking tool.

My problem is solved by using GoToolRelinking in DocumentChanged event. Thanks.