Skip to content

Commit 82e7636

Browse files
committed
Add backwards compatible EnumUtils.TryToString call
1 parent 2171a88 commit 82e7636

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Src/Newtonsoft.Json/Utilities/EnumUtils.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@ public static IList<T> GetFlagsValues<T>(T value) where T : struct
117117
return selectedFlagsValues;
118118
}
119119

120+
// Used by Newtonsoft.Json.Schema
121+
private static CamelCaseNamingStrategy _camelCaseNamingStrategy = new CamelCaseNamingStrategy();
122+
public static bool TryToString(Type enumType, object value, bool camelCase, out string name)
123+
{
124+
return TryToString(enumType, value, camelCase ? _camelCaseNamingStrategy : null, out name);
125+
}
126+
120127
public static bool TryToString(Type enumType, object value, NamingStrategy namingStrategy, out string name)
121128
{
122129
EnumInfo enumInfo = ValuesAndNamesPerEnum.Get(new StructMultiKey<Type, NamingStrategy>(enumType, namingStrategy));

0 commit comments

Comments
 (0)