From 82e76365f86c1e9ee624940fb1488a766c3bd12a Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Tue, 27 Nov 2018 22:55:57 +1300 Subject: [PATCH] Add backwards compatible EnumUtils.TryToString call --- Src/Newtonsoft.Json/Utilities/EnumUtils.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Src/Newtonsoft.Json/Utilities/EnumUtils.cs b/Src/Newtonsoft.Json/Utilities/EnumUtils.cs index 0a782f60..729670be 100644 --- a/Src/Newtonsoft.Json/Utilities/EnumUtils.cs +++ b/Src/Newtonsoft.Json/Utilities/EnumUtils.cs @@ -117,6 +117,13 @@ namespace Newtonsoft.Json.Utilities return selectedFlagsValues; } + // Used by Newtonsoft.Json.Schema + private static CamelCaseNamingStrategy _camelCaseNamingStrategy = new CamelCaseNamingStrategy(); + public static bool TryToString(Type enumType, object value, bool camelCase, out string name) + { + return TryToString(enumType, value, camelCase ? _camelCaseNamingStrategy : null, out name); + } + public static bool TryToString(Type enumType, object value, NamingStrategy namingStrategy, out string name) { EnumInfo enumInfo = ValuesAndNamesPerEnum.Get(new StructMultiKey(enumType, namingStrategy));