Make RequestParameters work for RT and perf

Around an 80% perf improvement
This commit is contained in:
Haacked
2013-10-27 20:31:46 -07:00
parent fbe0be1220
commit f6aa28f818
5 changed files with 136 additions and 54 deletions
+46 -1
View File
@@ -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
}
}
}