parent
d815329f71
commit
f714425619
|
|
@ -52,7 +52,9 @@ namespace Microsoft.AspNet.Mvc
|
||||||
{
|
{
|
||||||
return type.GetTypeInfo().ImplementedInterfaces.ToArray();
|
return type.GetTypeInfo().ImplementedInterfaces.ToArray();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if NETFX_CORE || K10
|
||||||
public static bool IsAssignableFrom([NotNull] this Type type, [NotNull] Type c)
|
public static bool IsAssignableFrom([NotNull] this Type type, [NotNull] Type c)
|
||||||
{
|
{
|
||||||
return type.GetTypeInfo().IsAssignableFrom(c.GetTypeInfo());
|
return type.GetTypeInfo().IsAssignableFrom(c.GetTypeInfo());
|
||||||
|
|
@ -61,17 +63,29 @@ namespace Microsoft.AspNet.Mvc
|
||||||
|
|
||||||
public static bool IsGenericType([NotNull] this Type type)
|
public static bool IsGenericType([NotNull] this Type type)
|
||||||
{
|
{
|
||||||
|
#if NETFX_CORE || K10
|
||||||
return type.GetTypeInfo().IsGenericType;
|
return type.GetTypeInfo().IsGenericType;
|
||||||
|
#else
|
||||||
|
return type.IsGenericType;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsInterface([NotNull] this Type type)
|
public static bool IsInterface([NotNull] this Type type)
|
||||||
{
|
{
|
||||||
|
#if NETFX_CORE || K10
|
||||||
return type.GetTypeInfo().IsInterface;
|
return type.GetTypeInfo().IsInterface;
|
||||||
|
#else
|
||||||
|
return type.IsInterface;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsValueType([NotNull] this Type type)
|
public static bool IsValueType([NotNull] this Type type)
|
||||||
{
|
{
|
||||||
|
#if NETFX_CORE || K10
|
||||||
return type.GetTypeInfo().IsValueType;
|
return type.GetTypeInfo().IsValueType;
|
||||||
|
#else
|
||||||
|
return type.IsValueType;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsCompatibleWith([NotNull] this Type type, object value)
|
public static bool IsCompatibleWith([NotNull] this Type type, object value)
|
||||||
|
|
@ -92,6 +106,8 @@ namespace Microsoft.AspNet.Mvc
|
||||||
|
|
||||||
public static bool HasStringConverter([NotNull] this Type type)
|
public static bool HasStringConverter([NotNull] this Type type)
|
||||||
{
|
{
|
||||||
|
// TODO: This depends on TypeConverter which does not exist in the CoreCLR.
|
||||||
|
// return TypeDescriptor.GetConverter(type).CanConvertFrom(typeof(string));
|
||||||
TypeInfo typeInfo = type.GetTypeInfo();
|
TypeInfo typeInfo = type.GetTypeInfo();
|
||||||
if (typeInfo.IsPrimitive || type == typeof(string))
|
if (typeInfo.IsPrimitive || type == typeof(string))
|
||||||
{
|
{
|
||||||
|
|
@ -102,7 +118,6 @@ namespace Microsoft.AspNet.Mvc
|
||||||
// Nullable<T> where T is a primitive type or has a type converter
|
// Nullable<T> where T is a primitive type or has a type converter
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue