Refactor
This commit is contained in:
parent
b124e19a87
commit
1d6e9c32ba
4 changed files with 50 additions and 13 deletions
13
Enums/TimeFormat.cs
Normal file
13
Enums/TimeFormat.cs
Normal file
|
|
@ -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
|
||||||
|
}
|
||||||
|
|
@ -7,8 +7,8 @@ global using System.Text;
|
||||||
global using System.Threading.Tasks;
|
global using System.Threading.Tasks;
|
||||||
global using System.Drawing;
|
global using System.Drawing;
|
||||||
global using Microsoft.Extensions.Logging;
|
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.Internal;
|
||||||
global using static Xorog.UniversalExtensions.InternalSheduler;
|
global using static Xorog.UniversalExtensions.InternalSheduler;
|
||||||
global using static Xorog.UniversalExtensions.Log;
|
global using static Xorog.UniversalExtensions.Log;
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
namespace Xorog.UniversalExtensions;
|
|
||||||
|
|
||||||
public class UniversalExtensionsEnums
|
|
||||||
{
|
|
||||||
public enum TimeFormat
|
|
||||||
{
|
|
||||||
MINUTES,
|
|
||||||
HOURS,
|
|
||||||
DAYS
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,7 +1,42 @@
|
||||||
namespace Xorog.UniversalExtensions;
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace Xorog.UniversalExtensions;
|
||||||
|
|
||||||
public static class 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);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Attaches a logger to UniversalExtensions. Used for Debug purposes.
|
/// Attaches a logger to UniversalExtensions. Used for Debug purposes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue