patch the serializer for our silly OAuth response format

This commit is contained in:
Brendan Forster
2014-10-06 16:05:44 -02:00
parent e239857ce6
commit 1edd8c377f

View File

@@ -1,4 +1,5 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
@@ -123,6 +124,17 @@ namespace Octokit.Internal
return Enum.Parse(underlyingType, stringValue, ignoreCase: true);
}
}
if (ReflectionUtils.IsTypeGenericeCollectionInterface(type))
{
// OAuth tokens might be a string of comma-separated values
// we should only try this if the return array is a collection of strings
var innerType = ReflectionUtils.GetGenericListElementType(type);
if (innerType.IsAssignableFrom(typeof(string)))
{
return stringValue.Split(',');
}
}
}
return base.DeserializeObject(value, type);