Private/New-OperationValidationResult.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

function New-OperationValidationResult {
    [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '', Scope='Function', Target='*')]
    param (
        [Parameter(Mandatory)]
        [string]$FileName,

        [Parameter(Mandatory)]
        [string]$Name,

        [Parameter(Mandatory)]
        [string]$Result,

        [string]$Module,

        [object]$RawResult,

        [object]$Error
    )

    $o = [pscustomobject]@{
        PSTypeName = 'OperationValidationResult'
        Module     = $Module
        FileName   = $FileName
        ShortName  = ([IO.Path]::GetFileName($FileName))
        Name       = $Name
        Result     = $Result
        Error      = $Error
        RawResult  = $RawResult
    }
    $toString = { return ('{0} ({1}): {2}' -f $this.Module, $this.FileName, $this.Name) }
    Add-Member -InputObject $o -MemberType ScriptMethod -Name ToString -Value $toString -Force
    $o
}