mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-21 06:35:11 +00:00
we should deserialize Urls in a specific way
This commit is contained in:
@@ -64,6 +64,15 @@ namespace Octokit.Internal
|
|||||||
var stringValue = value as string;
|
var stringValue = value as string;
|
||||||
if (stringValue != null)
|
if (stringValue != null)
|
||||||
{
|
{
|
||||||
|
if (ReflectionUtils.IsUri(type))
|
||||||
|
{
|
||||||
|
Uri result;
|
||||||
|
if (Uri.TryCreate(stringValue, UriKind.RelativeOrAbsolute, out result))
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ReflectionUtils.GetTypeInfo(type).IsEnum)
|
if (ReflectionUtils.GetTypeInfo(type).IsEnum)
|
||||||
{
|
{
|
||||||
return Enum.Parse(type, stringValue, ignoreCase: true);
|
return Enum.Parse(type, stringValue, ignoreCase: true);
|
||||||
|
|||||||
@@ -1667,6 +1667,11 @@ namespace Octokit
|
|||||||
return GetTypeInfo(type).IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>);
|
return GetTypeInfo(type).IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool IsUri(Type type)
|
||||||
|
{
|
||||||
|
return GetTypeInfo(type) == GetTypeInfo(typeof(Uri));
|
||||||
|
}
|
||||||
|
|
||||||
public static object ToNullableType(object obj, Type nullableType)
|
public static object ToNullableType(object obj, Type nullableType)
|
||||||
{
|
{
|
||||||
return obj == null ? null : Convert.ChangeType(obj, Nullable.GetUnderlyingType(nullableType), CultureInfo.InvariantCulture);
|
return obj == null ? null : Convert.ChangeType(obj, Nullable.GetUnderlyingType(nullableType), CultureInfo.InvariantCulture);
|
||||||
|
|||||||
Reference in New Issue
Block a user