mirror of
https://github.com/Smaug123/WoofWare.Whippet
synced 2025-10-05 15:58:39 +00:00
28 lines
786 B
Forth
28 lines
786 B
Forth
namespace WoofWare.Whippet
|
|
|
|
open System.IO
|
|
open System.Reflection
|
|
open System.Runtime.Loader
|
|
|
|
type Ctx (dll : FileInfo, runtimes : DirectoryInfo list) =
|
|
inherit AssemblyLoadContext ()
|
|
|
|
override this.Load (target : AssemblyName) : Assembly =
|
|
let localPath = Path.Combine (dll.Directory.FullName, $"%s{target.Name}.dll")
|
|
|
|
runtimes
|
|
|> List.tryPick (fun di ->
|
|
let path = Path.Combine (di.FullName, $"%s{target.Name}.dll")
|
|
|
|
if File.Exists path then
|
|
this.LoadFromAssemblyPath path |> Some
|
|
else
|
|
None
|
|
)
|
|
|> Option.defaultWith (fun () ->
|
|
if File.Exists localPath then
|
|
this.LoadFromAssemblyPath localPath
|
|
else
|
|
null
|
|
)
|