2 using System.Collections.Generic;
3 using System.ComponentModel;
5 using System.Reflection;
7 namespace Tizen.NUI.Internals
9 [EditorBrowsable(EditorBrowsableState.Never)]
10 internal static class ReflectionExtensions
12 public static FieldInfo GetField(this Type type, Func<FieldInfo, bool> predicate)
14 return GetFields(type).FirstOrDefault(predicate);
17 public static FieldInfo GetField(this Type type, string name)
19 return type.GetField(fi => fi.Name == name);
22 public static IEnumerable<FieldInfo> GetFields(this Type type)
24 return GetParts(type, i => i.DeclaredFields);
27 public static IEnumerable<PropertyInfo> GetProperties(this Type type)
29 return GetParts(type, ti => ti.DeclaredProperties);
32 public static PropertyInfo GetProperty(this Type type, string name)
37 System.Reflection.TypeInfo ti = t.GetTypeInfo();
38 PropertyInfo property = ti.GetDeclaredProperty(name);
48 public static bool IsAssignableFrom(this Type self, Type c)
50 return self.GetTypeInfo().IsAssignableFrom(c.GetTypeInfo());
53 public static bool IsInstanceOfType(this Type self, object o)
55 return self.GetTypeInfo().IsAssignableFrom(o.GetType().GetTypeInfo());
58 static IEnumerable<T> GetParts<T>(Type type, Func<System.Reflection.TypeInfo, IEnumerable<T>> selector)
63 System.Reflection.TypeInfo ti = t.GetTypeInfo();
64 foreach (T f in selector(ti))