mirror of
https://github.com/DarthAffe/StableDiffusion.NET.git
synced 2025-12-13 05:48:40 +00:00
Added event to be able to intercept library path creation
This commit is contained in:
parent
4b8faf24d0
commit
6d6bfe3fc6
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace StableDiffusion.NET;
|
namespace StableDiffusion.NET;
|
||||||
@ -23,6 +24,12 @@ public static class Backends
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Events
|
||||||
|
|
||||||
|
public static event EventHandler<LibraryPathCreatingEventArgs>? LibraryPathCreating;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
|
|
||||||
public static bool RegisterBackend(IBackend backend)
|
public static bool RegisterBackend(IBackend backend)
|
||||||
@ -40,5 +47,25 @@ public static class Backends
|
|||||||
public static bool UnregisterBackend(IBackend backend)
|
public static bool UnregisterBackend(IBackend backend)
|
||||||
=> CUSTOM_BACKENDS.Remove(backend);
|
=> CUSTOM_BACKENDS.Remove(backend);
|
||||||
|
|
||||||
|
internal static string GetFullPath(string os, string backend, string libName)
|
||||||
|
{
|
||||||
|
string path = Path.Combine("runtimes", os, "native", backend, libName);
|
||||||
|
return OnLibraryPathCreating(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string OnLibraryPathCreating(string path)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
LibraryPathCreatingEventArgs args = new(path);
|
||||||
|
LibraryPathCreating?.Invoke(null, args);
|
||||||
|
return args.Path;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user