PSParseHTML.Libraries.ps1

# PSParseHTML.Libraries.ps1
# Auto-generated by PowerForge. Do not edit.

$LibrariesByFolder = @{
    'Core' = @(
        'Lib\Core\PSParseHTML.PowerShell.dll'
        'Lib\Core\Acornima.dll'
        'Lib\Core\AngleSharp.Css.dll'
        'Lib\Core\AngleSharp.Diffing.dll'
        'Lib\Core\AngleSharp.dll'
        'Lib\Core\AngleSharp.Js.dll'
        'Lib\Core\HtmlAgilityPack.dll'
        'Lib\Core\HtmlTinkerX.dll'
        'Lib\Core\Jint.dll'
        'Lib\Core\Microsoft.Bcl.AsyncInterfaces.dll'
        'Lib\Core\Microsoft.Playwright.dll'
        'Lib\Core\NUglify.dll'
        'Lib\Core\OfficeIMO.Markdown.dll'
        'Lib\Core\OfficeIMO.Markdown.Html.dll'
        'Lib\Core\PreMailer.Net.dll'
        'Lib\Core\SixLabors.Fonts.dll'
        'Lib\Core\SixLabors.ImageSharp.dll'
        'Lib\Core\SixLabors.ImageSharp.Drawing.dll'
    )
    'Default' = @(
        'Lib\Default\PSParseHTML.PowerShell.dll'
        'Lib\Default\Acornima.dll'
        'Lib\Default\AngleSharp.Css.dll'
        'Lib\Default\AngleSharp.Diffing.dll'
        'Lib\Default\AngleSharp.dll'
        'Lib\Default\AngleSharp.Js.dll'
        'Lib\Default\HtmlAgilityPack.dll'
        'Lib\Default\HtmlTinkerX.dll'
        'Lib\Default\Jint.dll'
        'Lib\Default\Microsoft.Bcl.AsyncInterfaces.dll'
        'Lib\Default\Microsoft.Playwright.dll'
        'Lib\Default\NUglify.dll'
        'Lib\Default\OfficeIMO.Markdown.dll'
        'Lib\Default\OfficeIMO.Markdown.Html.dll'
        'Lib\Default\PreMailer.Net.dll'
        'Lib\Default\SixLabors.Fonts.dll'
        'Lib\Default\SixLabors.ImageSharp.dll'
        'Lib\Default\SixLabors.ImageSharp.Drawing.dll'
        'Lib\Default\System.Buffers.dll'
        'Lib\Default\System.ComponentModel.Annotations.dll'
        'Lib\Default\System.Memory.dll'
        'Lib\Default\System.Numerics.Vectors.dll'
        'Lib\Default\System.Runtime.CompilerServices.Unsafe.dll'
        'Lib\Default\System.Text.Encoding.CodePages.dll'
        'Lib\Default\System.Text.Encodings.Web.dll'
        'Lib\Default\System.Text.Json.dll'
        'Lib\Default\System.Threading.Channels.dll'
        'Lib\Default\System.Threading.Tasks.Extensions.dll'
        'Lib\Default\System.ValueTuple.dll'
    )
}


$AssemblyFolders = Get-ChildItem -Path $PSScriptRoot\Lib -Directory -ErrorAction SilentlyContinue

$Default = $false
$Core = $false
$Standard = $false
foreach ($A in $AssemblyFolders.Name) {
    if ($A -eq 'Default') {
        $Default = $true
    } elseif ($A -eq 'Core') {
        $Core = $true
    } elseif ($A -eq 'Standard') {
        $Standard = $true
    }
}
if ($Standard -and $Core -and $Default) {
    $FrameworkNet = 'Default'
    $Framework = 'Standard'
} elseif ($Standard -and $Core) {
    $Framework = 'Standard'
    $FrameworkNet = 'Standard'
} elseif ($Core -and $Default) {
    $Framework = 'Core'
    $FrameworkNet = 'Default'
} elseif ($Standard -and $Default) {
    $Framework = 'Standard'
    $FrameworkNet = 'Default'
} elseif ($Standard) {
    $Framework = 'Standard'
    $FrameworkNet = 'Standard'
} elseif ($Core) {
    $Framework = 'Core'
    $FrameworkNet = ''
} elseif ($Default) {
    $Framework = ''
    $FrameworkNet = 'Default'
} else {
    #Write-Error -Message 'No assemblies found'
}

if ($PSEdition -eq 'Core') {
    $LibFolder = $Framework
} else {
    $LibFolder = $FrameworkNet
}

$LibrariesToLoad = $LibrariesByFolder[$LibFolder]
if ($null -eq $LibrariesToLoad) { $LibrariesToLoad = @() }
foreach ($L in $LibrariesToLoad) {
    try {
        Add-Type -Path $PSScriptRoot\$L -ErrorAction Stop
    } catch {
        if ($_.Exception.Message -like '*Assembly with same name is already loaded*') {
            Write-Warning -Message "Assembly with same name is already loaded. Ignoring '$L'."
        } else {
            throw $_
        }
    }
}