using LibationFileManager; using System; #nullable enable 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 loads a named resource into the the UI framework's image format. public static Func LoadResourceImage => s_LoadResourceImage ?? DefaultLoadResourceImageImpl; public static void SetLoadImageDelegate(Func tryLoadImage) => s_LoadImage = tryLoadImage; public static void SetLoadResourceImageDelegate(Func tryLoadResourceImage) => s_LoadResourceImage = tryLoadResourceImage; private static Func? s_LoadImage; private static Func? s_LoadResourceImage; 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; } private static object? DefaultLoadResourceImageImpl(string resourceName) { Serilog.Log.Error("{LoadResourceImage} called without a delegate set. Resource name: {ResourceName}", nameof(LoadResourceImage), resourceName); return null; } } }