public virtual bool HandleDeleteCommand(Command cmd)
{
CheckDisposed();
var obj = GetObjectForMenusToOperateOn();
// Build a list of neighboring slices, ordered by proximity (max of 40 either way...don't want to build too much
// of a lazy view).
var dataTree = ContainingDataTree;
List<Slice> closeSlices = GetCloseSlices();
bool result = false;
if (obj == null)
{
throw new ConfigurationException("Slice:GetObjectHvoForMenusToOperateOn is either messed up or should not have been called, because it could not find the object to be deleted.", m_configurationNode);
}
else
{
DataTree dt = ContainingDataTree;
try
{
dt.SetCurrentObjectFlids(obj.Hvo, 0);
using (CmObjectUi ui = CmObjectUi.MakeUi(m_cache, obj.Hvo))
{
ui.Mediator = m_mediator;
result = ui.DeleteUnderlyingObject();
}
}
finally
{
dt.ClearCurrentObjectFlids();
}
}
// The slice will likely be disposed in the DeleteUnderlyingObject call,
// so make sure we aren't collected until we leave this method, at least.
GC.KeepAlive(this);
dataTree.SelectFirstPossibleSlice(closeSlices);
return result;
}