Skip to content

Commit

Permalink
Remove unnecessary serialization of enum values (#26)
Browse files Browse the repository at this point in the history
OCR-345
  • Loading branch information
Ann authored Dec 18, 2019
1 parent 6aeeec5 commit 8e22e09
Showing 1 changed file with 0 additions and 21 deletions.
21 changes: 0 additions & 21 deletions src/Abbyy.CloudSdk.V2.Client/Utils/Serializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,34 +72,13 @@ private static string GetCollectionValues(IEnumerable collection)

foreach (var element in collection)
{
var elementType = element.GetType();
var value = element.ToString();

if (elementType.IsEnum)
{
value = GetEnumValue(elementType, value);
}

values.Add(value);
}

return string.Join(",", values);
}

private static string GetEnumValue(Type enumType, string value)
{
var memberInfo = enumType.GetMember(value);

var attribute = memberInfo[0]
.GetCustomAttribute(typeof(JsonPropertyAttribute)) as JsonPropertyAttribute;

var actualValue = attribute is null ?
char.ToLowerInvariant(value[0]) + value.Substring(1) :
attribute.PropertyName;

return actualValue;
}

private static string GetPropertyName(PropertyInfo prop)
{
var attribute = prop
Expand Down

0 comments on commit 8e22e09

Please sign in to comment.