Skip to content

Commit 60aed32

Browse files
Merge pull request #1235 from TransactionProcessing/task/#1234_getvalueordefault_handle_enums
Handle enum types in ConfigurationReader value parsing
2 parents 405349c + 85fd183 commit 60aed32

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

Shared/General/ConfigurationReader.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ public static T GetValueOrDefault<T>(String sectionName, String keyName, T defau
8686
return defaultValue;
8787
}
8888

89+
if (typeof(T).IsEnum) {
90+
return (T)Enum.Parse(typeof(T), value, ignoreCase: true);
91+
}
92+
8993
return (T)Convert.ChangeType(value, typeof(T));
9094
}
9195
catch (KeyNotFoundException)

0 commit comments

Comments
 (0)