Option Strict On
Option Explicit On

Namespace Nexamas.UI.PropertyGrid

    ''' <summary>
    ''' Internal edit result returned by property value commits.
    ''' </summary>
    Friend NotInheritable Class MASPropertyGridEditResult

        Friend Sub New(success As Boolean,
                       propertyName As String,
                       oldValue As Object,
                       newValue As Object,
                       message As String)
            Me.Success = success
            Me.PropertyName = MASPropertyGridText.Normalize(propertyName, String.Empty)
            Me.OldValue = oldValue
            Me.NewValue = newValue
            Me.Message = MASPropertyGridText.Normalize(message, String.Empty)
        End Sub

        Friend ReadOnly Property Success As Boolean
        Friend ReadOnly Property PropertyName As String
        Friend ReadOnly Property OldValue As Object
        Friend ReadOnly Property NewValue As Object
        Friend ReadOnly Property Message As String

        Friend Shared Function Changed(propertyName As String, oldValue As Object, newValue As Object) As MASPropertyGridEditResult
            Return New MASPropertyGridEditResult(True, propertyName, oldValue, newValue, "Value changed.")
        End Function

        Friend Shared Function Unchanged(propertyName As String, value As Object) As MASPropertyGridEditResult
            Return New MASPropertyGridEditResult(True, propertyName, value, value, "Value unchanged.")
        End Function

        Friend Shared Function Failed(propertyName As String, message As String) As MASPropertyGridEditResult
            Return New MASPropertyGridEditResult(False, propertyName, Nothing, Nothing, message)
        End Function

    End Class

End Namespace
