From fd2028787038f6a7fcf8fda3fa82750cfd37b7b2 Mon Sep 17 00:00:00 2001 From: Victor-Philipp Negoescu Date: Tue, 25 Jul 2017 02:07:18 +0200 Subject: [PATCH] OptionsFramework added --- Extensions/CommonExtensions.cs | 10 ++++++++-- OptionsFramework.csproj | 8 ++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Extensions/CommonExtensions.cs b/Extensions/CommonExtensions.cs index fd4d987..f30b5c6 100644 --- a/Extensions/CommonExtensions.cs +++ b/Extensions/CommonExtensions.cs @@ -10,7 +10,10 @@ public static string GetPropertyDescription(this T value, string propertyName var fi = value.GetType().GetProperty(propertyName); var attributes = (AbstractOptionsAttribute[]) fi.GetCustomAttributes(typeof(AbstractOptionsAttribute), false); - return attributes.Length > 0 ? attributes[0].Description : throw new Exception($"Property {propertyName} wasn't annotated with AbstractOptionsAttribute"); + if (attributes.Length <= 0) { + throw new Exception($"Property {propertyName} wasn't annotated with AbstractOptionsAttribute"); + } + return attributes[0].Description; } public static string GetPropertyGroup(this T value, string propertyName) @@ -18,7 +21,10 @@ public static string GetPropertyGroup(this T value, string propertyName) var fi = value.GetType().GetProperty(propertyName); var attributes = (AbstractOptionsAttribute[]) fi.GetCustomAttributes(typeof(AbstractOptionsAttribute), false); - return attributes.Length > 0 ? attributes[0].Group : throw new Exception($"Property {propertyName} wasn't annotated with AbstractOptionsAttribute"); + if (attributes.Length <= 0) { + throw new Exception($"Property {propertyName} wasn't annotated with AbstractOptionsAttribute"); + } + return attributes[0].Group; } public static TR GetAttribute(this T value, string propertyName)where TR : Attribute diff --git a/OptionsFramework.csproj b/OptionsFramework.csproj index 2022061..58857dd 100644 --- a/OptionsFramework.csproj +++ b/OptionsFramework.csproj @@ -48,18 +48,18 @@ - C:\Games\Steam\steamapps\common\Cities_Skylines\Cities_Data\Managed\Assembly-CSharp.dll + D:\Games\Steam\steamapps\common\Cities_Skylines\Cities_Data\Managed\Assembly-CSharp.dll - C:\Games\Steam\steamapps\common\Cities_Skylines\Cities_Data\Managed\ColossalManaged.dll + D:\Games\Steam\steamapps\common\Cities_Skylines\Cities_Data\Managed\ColossalManaged.dll - C:\Games\Steam\steamapps\common\Cities_Skylines\Cities_Data\Managed\ICities.dll + D:\Games\Steam\steamapps\common\Cities_Skylines\Cities_Data\Managed\ICities.dll - C:\Games\Steam\steamapps\common\Cities_Skylines\Cities_Data\Managed\UnityEngine.dll + D:\Games\Steam\steamapps\common\Cities_Skylines\Cities_Data\Managed\UnityEngine.dll