ConfigLoadPropertyErrorEventArgs Class

  ConfigLoadPropertyErrorEventArgs
 ErrorCode
 Message
 PropertyPath
property InnerException

Visual Basic

Syntax

Class ConfigLoadPropertyErrorEventArgs

Sample Code

 
' This method handles PropertyError events that occur while 
' loading the configuration of an object.
Public Sub OnLoadPropertyError(ByVal loader As Mpx.ConfigLoader, 
ByVal e As Mpx.ConfigLoadPropertyErrorEventArgs)
    Dim msg As String = "Warning: "

    Select Case e.ErrorCode
        Case Mpx.ConfigLoadErrorCode.Missing
            If e.PropertyPath.StartsWith("Controller.Can") Then
                ' Ignore missing Can and CanNode objects
                Return
            End If
        Case Mpx.ConfigLoadErrorCode.Unsupported
        Case Else
            ' For all other errors, print an error message and 
            ' cancel the load.
            msg = "Error: "

            ' Cancel the load operation
            loader.Cancel()
    End Select

    ' Print an informative message
    ' Example output:
    ' Error: Controller.Axis[2]: Axis is not enabled
    msg += e.PropertyPath
    msg += ": "
    msg += e.Message
    System.Console.WriteLine(msg)
End Sub


Sample Application

 

C#

Syntax

class ConfigLoadPropertyErrorEventArgs

Sample Code

 

// 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);
}

See Also

Serialization Overview | ConfigLoader | ConfigLoadErrorCode