diff --git a/Enums/TimeFormat.cs b/Enums/TimeFormat.cs new file mode 100644 index 0000000..832f4be --- /dev/null +++ b/Enums/TimeFormat.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Xorog.UniversalExtensions.Enums; +public enum TimeFormat +{ + MINUTES, + HOURS, + DAYS +} diff --git a/Global.cs b/Global.cs index 042e4fc..05154bc 100644 --- a/Global.cs +++ b/Global.cs @@ -7,8 +7,8 @@ global using System.Text; global using System.Threading.Tasks; global using System.Drawing; global using Microsoft.Extensions.Logging; +global using Xorog.UniversalExtensions.Enums; -global using static Xorog.UniversalExtensions.UniversalExtensionsEnums; global using static Xorog.UniversalExtensions.Internal; global using static Xorog.UniversalExtensions.InternalSheduler; global using static Xorog.UniversalExtensions.Log; \ No newline at end of file diff --git a/UniversalExtensions.Enums.cs b/UniversalExtensions.Enums.cs deleted file mode 100644 index ff9f968..0000000 --- a/UniversalExtensions.Enums.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Xorog.UniversalExtensions; - -public class UniversalExtensionsEnums -{ - public enum TimeFormat - { - MINUTES, - HOURS, - DAYS - } -} \ No newline at end of file diff --git a/UniversalExtensions.cs b/UniversalExtensions.cs index de7ddf4..5c74aec 100644 --- a/UniversalExtensions.cs +++ b/UniversalExtensions.cs @@ -1,7 +1,42 @@ -namespace Xorog.UniversalExtensions; +using System.Reflection; + +namespace Xorog.UniversalExtensions; public static class UniversalExtensions { + public static void LoadAllReferencedAssemblies(AppDomain domain) + { + _logger?.LogDebug("Loading all assemblies.."); + + var assemblyCount = 0; + foreach (Assembly assembly in domain.GetAssemblies()) + { + LoadReferencedAssembly(assembly); + } + + void LoadReferencedAssembly(Assembly assembly) + { + try + { + foreach (AssemblyName name in assembly.GetReferencedAssemblies()) + { + if (!AppDomain.CurrentDomain.GetAssemblies().Any(a => a.FullName == name.FullName)) + { + assemblyCount++; + _logger?.LogDebug("Loading {Name}..", name.Name); + LoadReferencedAssembly(Assembly.Load(name)); + } + } + } + catch (Exception ex) + { + _logger?.LogError("Failed to load an assembly", ex); + } + } + + _logger?.LogInformation("Loaded {assemblyCount} assemblies.", assemblyCount); + } + /// /// Attaches a logger to UniversalExtensions. Used for Debug purposes. ///