mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-20 22:25:12 +00:00
Implement IssuesClient and interface
This required updating our serialization strategy so we handle enums better.
This commit is contained in:
@@ -50,6 +50,37 @@ namespace Octokit.Internal
|
||||
output = obj;
|
||||
return true;
|
||||
}
|
||||
|
||||
[SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase",
|
||||
Justification = "The API expects lowercase values")]
|
||||
protected override object SerializeEnum(Enum p)
|
||||
{
|
||||
return p.ToString().ToLowerInvariant();
|
||||
}
|
||||
|
||||
// Overridden to handle enums.
|
||||
public override object DeserializeObject(object value, Type type)
|
||||
{
|
||||
var stringValue = value as string;
|
||||
if (stringValue != null)
|
||||
{
|
||||
if (ReflectionUtils.GetTypeInfo(type).IsEnum)
|
||||
{
|
||||
return Enum.Parse(type, stringValue, ignoreCase: true);
|
||||
}
|
||||
|
||||
if (ReflectionUtils.IsNullableType(type))
|
||||
{
|
||||
var underlyingType = Nullable.GetUnderlyingType(type);
|
||||
if (ReflectionUtils.GetTypeInfo(underlyingType).IsEnum)
|
||||
{
|
||||
return Enum.Parse(underlyingType, stringValue, ignoreCase: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return base.DeserializeObject(value, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user