Merge remote-tracking branch 'origin/master' into dev

This commit is contained in:
JohnCorby 2022-02-26 02:06:18 -08:00
commit 8cb6a0b568

View File

@ -118,28 +118,28 @@ public class QSBCore : ModBehaviour
} }
} }
private static void InitializeAssemblies() private static void InitializeAssemblies()
{
DebugLog.DebugWrite("Running RuntimeInitializeOnLoad methods for our assemblies", MessageType.Info);
foreach (var path in Directory.EnumerateFiles(Helper.Manifest.ModFolderPath, "*.dll"))
{ {
DebugLog.DebugWrite("Running RuntimeInitializeOnLoad methods for our assemblies", MessageType.Info); var assembly = Assembly.LoadFile(path);
foreach (var path in Directory.EnumerateFiles(Helper.Manifest.ModFolderPath, "*.dll")) if (Path.GetFileNameWithoutExtension(path) == "ProxyScripts")
{ {
var assembly = Assembly.LoadFile(path); continue;
if (Path.GetFileNameWithoutExtension(path) == "ProxyScripts")
{
continue;
}
DebugLog.DebugWrite(assembly.ToString());
assembly
.GetTypes()
.SelectMany(x => x.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.DeclaredOnly))
.Where(x => x.IsDefined(typeof(RuntimeInitializeOnLoadMethodAttribute)))
.ForEach(x => x.Invoke(null, null));
} }
DebugLog.DebugWrite("Assemblies initialized", MessageType.Success); DebugLog.DebugWrite(assembly.ToString());
assembly
.GetTypes()
.SelectMany(x => x.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.DeclaredOnly))
.Where(x => x.IsDefined(typeof(RuntimeInitializeOnLoadMethodAttribute)))
.ForEach(x => x.Invoke(null, null));
} }
DebugLog.DebugWrite("Assemblies initialized", MessageType.Success);
}
public override void Configure(IModConfig config) => DefaultServerIP = config.GetSettingsValue<string>("defaultServerIP"); public override void Configure(IModConfig config) => DefaultServerIP = config.GetSettingsValue<string>("defaultServerIP");
private void Update() private void Update()