From afe54fb3570d1587bd78df821df42190d792c26d Mon Sep 17 00:00:00 2001 From: iopietro Date: Mon, 27 Apr 2020 18:01:18 +0200 Subject: [PATCH] Changes and additions +Moved the ReflectionExtensions file to EXILED_Main extensions folder and renamed it to Reflection. +Added Config extensions. --- EXILED_Events/EXILED_Events.csproj | 5 ++-- EXILED_Idler/EXILED_Idler.csproj | 2 +- EXILED_Main/EXILED_Main.csproj | 6 +++-- EXILED_Main/Extensions/Config.cs | 25 +++++++++++++++++++ .../Extensions/Reflection.cs | 4 +-- 5 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 EXILED_Main/Extensions/Config.cs rename EXILED_Events/ReflectionExtensions.cs => EXILED_Main/Extensions/Reflection.cs (87%) diff --git a/EXILED_Events/EXILED_Events.csproj b/EXILED_Events/EXILED_Events.csproj index 708518823b..f6e3a52429 100644 --- a/EXILED_Events/EXILED_Events.csproj +++ b/EXILED_Events/EXILED_Events.csproj @@ -39,7 +39,7 @@ ..\References\0Harmony.dll - ..\..\References\Assembly-CSharp_publicized.dll + ..\References\Assembly-CSharp.dll ..\References\Assembly-CSharp-firstpass.dll @@ -245,7 +245,6 @@ - @@ -255,7 +254,7 @@ - + - + \ No newline at end of file diff --git a/EXILED_Main/Extensions/Config.cs b/EXILED_Main/Extensions/Config.cs new file mode 100644 index 0000000000..6257545e49 --- /dev/null +++ b/EXILED_Main/Extensions/Config.cs @@ -0,0 +1,25 @@ +using System.Collections.Generic; + +namespace EXILED.Extensions +{ + public static class Config + { + public static Dictionary GetStringDictionary(this YamlConfig config, string key, Dictionary defaultValue) + { + var dictionary = config.GetStringDictionary(key); + + if (dictionary?.Count == 0) return defaultValue; + + return dictionary; + } + + public static List GetStringList(this YamlConfig config, string key, List defaultValue) + { + var list = config.GetStringList(key); + + if (list?.Count == 0) return defaultValue; + + return list; + } + } +} diff --git a/EXILED_Events/ReflectionExtensions.cs b/EXILED_Main/Extensions/Reflection.cs similarity index 87% rename from EXILED_Events/ReflectionExtensions.cs rename to EXILED_Main/Extensions/Reflection.cs index 81a426bbd3..b75c976073 100644 --- a/EXILED_Events/ReflectionExtensions.cs +++ b/EXILED_Main/Extensions/Reflection.cs @@ -1,9 +1,9 @@ using System; using System.Reflection; -namespace EXILED +namespace EXILED.Extensions { - public static class ReflectionExtensions + public static class Reflection { public static void InvokeStaticMethod(this Type type, string methodName, object[] param) {