internal void SendModelEvent(Guid modelGuid, string eventName, int value)
{
var retrievedModel = GetModelInternal(modelGuid);
if (retrievedModel == null)
throw new InvalidOperationException("SendModelEvent: Model not found");
var handled = false;
var nodeModel = retrievedModel as NodeModel;
if (nodeModel != null)
{
using (new UndoRedoRecorder.ModelModificationUndoHelper(undoRecorder, nodeModel))
{
handled = nodeModel.HandleModelEvent(eventName, value, undoRecorder);
}
}
else
{
// Perform generic undo recording for models other than node.
RecordModelForModification(retrievedModel, UndoRecorder);
handled = retrievedModel.HandleModelEvent(eventName, value, undoRecorder);
}
if (!handled) // Method call was not handled by any derived class.
{
string type = retrievedModel.GetType().FullName;
string message = string.Format(
"ModelBase.HandleModelEvent call not handled.\n\n" +
"Model type: {0}\n" +
"Model GUID: {1}\n" +
"Event name: {2}",
type, modelGuid, eventName);
// All 'HandleModelEvent' calls must be handled by one of
// the ModelBase derived classes that the 'SendModelEvent'
// is intended for.
throw new InvalidOperationException(message);
}
HasUnsavedChanges = true;
}