using LibationFileManager; using System; namespace LibationUiBase; public static class BaseUtil { /// A delegate that loads image bytes into the the UI framework's image format. public static Func LoadImage => s_LoadImage ?? DefaultLoadImageImpl; /// A delegate that reports whether the UI framework is currently using a dark theme. public static Func IsDarkMode => s_IsDarkMode ?? DefaultIsDarkModeImpl; public static void SetLoadImageDelegate(Func tryLoadImage) => s_LoadImage = tryLoadImage; public static void SetIsDarkModeDelegate(Func isDarkMode) => s_IsDarkMode = isDarkMode; private static Func? s_LoadImage; private static Func? s_IsDarkMode; private static object? DefaultLoadImageImpl(byte[]? imageBytes, PictureSize size) { Serilog.Log.Error("{LoadImage} called without a delegate set. Picture size: {PictureSize}", nameof(LoadImage), size); return null; } /// Light is the safe assumption for hosts without a theme, like the CLI and tests. private static bool DefaultIsDarkModeImpl() => false; }