I would like to hook into deletion of an MDriven object to do some checks and maybe cancel/prevent deletion. I seem to recall that this is possible, but can't find how to do it. The class is persistent, in case it matters.
Asked
Active
Viewed 35 times
1
-
`ICache.SetExistenceState` seems to be a point of interest, but looks like the only way to prevent deletion would be to throw an exception. Also, it's a central point while I want this for one particular class. Is there a better way? – Kjell Rilbe Jun 07 '18 at 09:17
-
Found `partial void PreDelete(ref System.Boolean canDelete)` which seems to be what I'm looking for. But where would this be documented? It's not exposed in any interface or superclass as far as I can see. – Kjell Rilbe Jun 07 '18 at 12:05
-
I noticed now that `PreDelete` is a partial method, not a virtual one. But it's well hidden inside the Constructors #region. – Kjell Rilbe Jun 07 '18 at 12:27
1 Answers
2
The PreDelete is the right way to do this. Return canDelete=false to stop delete.
There are several good partial methods declared per class - they are all good plug points where you can inject your own functionality.

Hans Karlsen
- 2,275
- 1
- 15
- 15