Transferetto.Libraries.ps1

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

$LibrariesByFolder = @{
    'Core' = @(
        'Lib\Core\Transferetto.PowerShell.dll'
        'Lib\Core\BouncyCastle.Cryptography.dll'
        'Lib\Core\FluentFTP.dll'
        'Lib\Core\FluentFTP.GnuTLS.dll'
        'Lib\Core\Microsoft.Extensions.DependencyInjection.Abstractions.dll'
        'Lib\Core\Microsoft.Extensions.Logging.Abstractions.dll'
        'Lib\Core\Renci.SshNet.dll'
        'Lib\Core\Transferetto.dll'
    )
    'Default' = @(
        'Lib\Default\Transferetto.PowerShell.dll'
        'Lib\Default\BouncyCastle.Cryptography.dll'
        'Lib\Default\FluentFTP.dll'
        'Lib\Default\FluentFTP.GnuTLS.dll'
        'Lib\Default\Microsoft.Bcl.AsyncInterfaces.dll'
        'Lib\Default\Microsoft.Extensions.DependencyInjection.Abstractions.dll'
        'Lib\Default\Microsoft.Extensions.Logging.Abstractions.dll'
        'Lib\Default\Renci.SshNet.dll'
        'Lib\Default\System.Buffers.dll'
        'Lib\Default\System.Formats.Asn1.dll'
        'Lib\Default\System.Memory.dll'
        'Lib\Default\System.Numerics.Vectors.dll'
        'Lib\Default\System.Runtime.CompilerServices.Unsafe.dll'
        'Lib\Default\System.Threading.Tasks.Extensions.dll'
        'Lib\Default\System.ValueTuple.dll'
        'Lib\Default\Transferetto.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 {
        $LibraryPathParts = @($PSScriptRoot) + @($L -split '[\\/]' | Where-Object { -not [string]::IsNullOrWhiteSpace($_) })
        $LibraryPath = [IO.Path]::Combine([string[]] $LibraryPathParts)
        try {
            $null = [System.Reflection.AssemblyName]::GetAssemblyName($LibraryPath)
        } catch [System.BadImageFormatException] {
            Write-Verbose -Message "Skipping non-managed library '$L'."
            continue
        }

        Add-Type -Path $LibraryPath -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 $_
        }
    }
}