Skip to content

Commit

Permalink
OptionsFramework added
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorPhilipp committed Jul 25, 2017
1 parent 5203a2a commit fd20287
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
10 changes: 8 additions & 2 deletions Extensions/CommonExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,21 @@ public static string GetPropertyDescription<T>(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<T>(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<T, TR>(this T value, string propertyName)where TR : Attribute
Expand Down
8 changes: 4 additions & 4 deletions OptionsFramework.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,18 @@
</ItemGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>C:\Games\Steam\steamapps\common\Cities_Skylines\Cities_Data\Managed\Assembly-CSharp.dll</HintPath>
<HintPath>D:\Games\Steam\steamapps\common\Cities_Skylines\Cities_Data\Managed\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="ColossalManaged">
<HintPath>C:\Games\Steam\steamapps\common\Cities_Skylines\Cities_Data\Managed\ColossalManaged.dll</HintPath>
<HintPath>D:\Games\Steam\steamapps\common\Cities_Skylines\Cities_Data\Managed\ColossalManaged.dll</HintPath>
</Reference>
<Reference Include="ICities">
<HintPath>C:\Games\Steam\steamapps\common\Cities_Skylines\Cities_Data\Managed\ICities.dll</HintPath>
<HintPath>D:\Games\Steam\steamapps\common\Cities_Skylines\Cities_Data\Managed\ICities.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine">
<HintPath>C:\Games\Steam\steamapps\common\Cities_Skylines\Cities_Data\Managed\UnityEngine.dll</HintPath>
<HintPath>D:\Games\Steam\steamapps\common\Cities_Skylines\Cities_Data\Managed\UnityEngine.dll</HintPath>
</Reference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down

0 comments on commit fd20287

Please sign in to comment.