private void ConnectPins(CPinViewModel source, CPinViewModel target) { CNodeConnectionViewModel newConnection = new CNodeConnectionViewModel(source, target, this); void Redo() { newConnection.Connect(); } void Undo() { newConnection.Disconnect(); } Redo(); UndoRedoUtility.Record(new CRelayUndoItem(Undo, Redo)); }