mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-05 11:40:42 +00:00
Make RequestParameters work for RT and perf
Around an 80% perf improvement
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
@@ -11,7 +15,48 @@ namespace Octokit
|
||||
|
||||
public static bool IsNullable(this Type type)
|
||||
{
|
||||
return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>);
|
||||
return type.GetTypeInfo().IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>);
|
||||
}
|
||||
|
||||
#if !NETFX_CORE
|
||||
public static Type GetTypeInfo(this Type type)
|
||||
{
|
||||
return type;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if NETFX_CORE
|
||||
public static IEnumerable<MemberInfo> GetMember(this Type type, string name)
|
||||
{
|
||||
return type.GetTypeInfo().DeclaredMembers.Where(m => m.Name == name);
|
||||
}
|
||||
|
||||
public static bool IsAssignableFrom(this Type type, Type otherType)
|
||||
{
|
||||
return type.GetTypeInfo().IsAssignableFrom(otherType.GetTypeInfo());
|
||||
}
|
||||
#endif
|
||||
public static IEnumerable<PropertyInfo> GetAllProperties(this Type type)
|
||||
{
|
||||
#if NETFX_CORE
|
||||
var typeInfo = type.GetTypeInfo();
|
||||
var properties = typeInfo.DeclaredProperties;
|
||||
|
||||
var baseType = typeInfo.BaseType;
|
||||
|
||||
return baseType == null ? properties : properties.Concat(baseType.GetAllProperties());
|
||||
#else
|
||||
return type.GetProperties(BindingFlags.Instance | BindingFlags.Public);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static bool IsEnumeration(this Type type)
|
||||
{
|
||||
#if NETFX_CORE
|
||||
return type.GetTypeInfo().IsEnum;
|
||||
#else
|
||||
return type.IsEnum;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user