// This method handles PropertyError events that occur while loading
// configuration to an object.
public void OnLoadPropertyError(Mpx.ConfigLoader loader,
Mpx.ConfigLoadPropertyErrorEventArgs e)
{
string msg;
if (e.ErrorCode == Mpx.ConfigLoadErrorCode.Missing)
{
if (e.PropertyPath.StartsWith("Controller.Can"))
{
// Ignore missing Can and CanNode objects
return;
}
// A property is missing in the config file. Print a warning.
msg = "Warning: ";
}
else
{
// For all other errors, print an error message and
// cancel the save.
msg = "Error: ";
// Cancel the load operation
loader.Cancel();
}
// Print an informative message
// Example output:
// ERROR: Controller.Axis[2]: Axis is not enabled
msg += e.PropertyPath
+ ": "
+ e.Message
+ "\n";
System.Console.Write(msg);
}
|