You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.4 KiB
52 lines
1.4 KiB
#if !UNITY_METRO |
|
|
|
using System; |
|
using System.Collections.Generic; |
|
using System.Reflection; |
|
using System.Runtime.CompilerServices; |
|
using System.Text; |
|
|
|
namespace MessagePack.Internal |
|
{ |
|
internal static class ReflectionExtensions |
|
{ |
|
public static bool IsNullable(this System.Reflection.TypeInfo type) |
|
{ |
|
return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(System.Nullable<>); |
|
} |
|
|
|
public static bool IsPublic(this System.Reflection.TypeInfo type) |
|
{ |
|
return type.IsPublic; |
|
} |
|
|
|
public static bool IsAnonymous(this System.Reflection.TypeInfo type) |
|
{ |
|
return type.GetCustomAttribute<CompilerGeneratedAttribute>() != null |
|
&& type.IsGenericType && type.Name.Contains("AnonymousType") |
|
&& (type.Name.StartsWith("<>") || type.Name.StartsWith("VB$")) |
|
&& (type.Attributes & TypeAttributes.NotPublic) == TypeAttributes.NotPublic; |
|
} |
|
|
|
#if NETSTANDARD1_4 |
|
|
|
public static bool IsConstructedGenericType(this System.Reflection.TypeInfo type) |
|
{ |
|
return type.AsType().IsConstructedGenericType; |
|
} |
|
|
|
public static MethodInfo GetGetMethod(this PropertyInfo propInfo) |
|
{ |
|
return propInfo.GetMethod; |
|
} |
|
|
|
public static MethodInfo GetSetMethod(this PropertyInfo propInfo) |
|
{ |
|
return propInfo.SetMethod; |
|
} |
|
|
|
#endif |
|
} |
|
} |
|
|
|
#endif |