Option Strict On
Option Explicit On

Namespace Nexamas.UI.CommandActions

     ''' <summary>
     ''' Immutable result returned by the Command / Action System single execution route.
     ''' </summary>
    Friend NotInheritable Class MASCommandInvocationResult

        Friend Sub New(commandId As String,
                       status As MASCommandInvocationStatus,
                       sourceKind As MASCommandBindingSurfaceKind,
                       message As String)
            Me.CommandId = MASCommandRegistry.NormalizeCommandId(commandId)
            Me.Status = status
            Me.SourceKind = sourceKind
            Me.Message = If(message, String.Empty)
        End Sub

        Friend ReadOnly Property CommandId As String
        Friend ReadOnly Property Status As MASCommandInvocationStatus
        Friend ReadOnly Property SourceKind As MASCommandBindingSurfaceKind
        Friend ReadOnly Property Message As String

        Friend ReadOnly Property Executed As Boolean
            Get
                Return Status = MASCommandInvocationStatus.Executed
            End Get
        End Property

        Friend Shared Function Missing(commandId As String,
                                       sourceKind As MASCommandBindingSurfaceKind) As MASCommandInvocationResult
            Return New MASCommandInvocationResult(commandId, MASCommandInvocationStatus.Missing, sourceKind, "Command was not registered.")
        End Function

        Friend Shared Function Disabled(commandId As String,
                                        sourceKind As MASCommandBindingSurfaceKind) As MASCommandInvocationResult
            Return New MASCommandInvocationResult(commandId, MASCommandInvocationStatus.Disabled, sourceKind, "Command is currently disabled.")
        End Function

        Friend Shared Function NoShortcutMatch() As MASCommandInvocationResult
            Return New MASCommandInvocationResult(String.Empty, MASCommandInvocationStatus.NoShortcutMatch, MASCommandBindingSurfaceKind.Shortcut, "No command shortcut matched the input gesture.")
        End Function

        Friend Shared Function Success(commandId As String,
                                       sourceKind As MASCommandBindingSurfaceKind) As MASCommandInvocationResult
            Return New MASCommandInvocationResult(commandId, MASCommandInvocationStatus.Executed, sourceKind, String.Empty)
        End Function

        Friend Shared Function Failed(commandId As String,
                                      sourceKind As MASCommandBindingSurfaceKind,
                                      message As String) As MASCommandInvocationResult
            Return New MASCommandInvocationResult(commandId, MASCommandInvocationStatus.Failed, sourceKind, message)
        End Function

    End Class

End Namespace
