Types/OpenPackage/get_Lexicon.ps1
|
<# .SYNOPSIS Gets any lexicons .DESCRIPTION Gets all at protocol lexicons in the package A lexicon is defined by the presence of three keys: * `id` * `lexicon` * `defs The output will be a table mapping ids to contents. #> [OutputType([Ordered])] param() $allLexicons = [Ordered]@{} # Get every part foreach ($part in $this.GetParts()) { # and ignore any part that is not json. if ($part.Uri -notmatch '\.json$') { continue } # Also ignore any package-lock files if ($part.Uri -match 'package-lock') { continue } # If there is no reader, continue if (-not $part.Reader) { continue } try { # Try to read our data $partData = $part.Read() # ignore any arrays if ($partData -is [Object[]]) { continue } # If the data has a .lexicon, .id, and .defs if ($partData.lexicon -and $partData.id -and $partData.defs ) { # store it in our lexicons table. $allLexicons[$partData.id] = $partData } } catch { Write-Warning "$($part.Uri) read error $($_)" continue } } # return all of the lexicons we found. return $allLexicons |