2 using System.Collections.Generic;
3 using System.ComponentModel;
5 using System.Reflection;
7 namespace Tizen.NUI.Binding.Internals
9 internal static class ReflectionExtensions
11 public static FieldInfo GetField(this Type type, Func<FieldInfo, bool> predicate)
13 return GetFields(type).FirstOrDefault(predicate);
16 public static FieldInfo GetField(this Type type, string name)
18 return type.GetField(fi => fi.Name == name);
21 public static IEnumerable<FieldInfo> GetFields(this Type type)
23 return GetParts(type, i => i.DeclaredFields);
26 public static IEnumerable<PropertyInfo> GetProperties(this Type type)
28 return GetParts(type, ti => ti.DeclaredProperties);
31 public static PropertyInfo GetProperty(this Type type, string name)
36 System.Reflection.TypeInfo ti = t.GetTypeInfo();
37 PropertyInfo property = ti.GetDeclaredProperty(name);
47 public static bool IsAssignableFrom(this Type self, Type c)
49 return self.GetTypeInfo().IsAssignableFrom(c.GetTypeInfo());
52 public static bool IsInstanceOfType(this Type self, object o)
54 return self.GetTypeInfo().IsAssignableFrom(o.GetType().GetTypeInfo());
57 static IEnumerable<T> GetParts<T>(Type type, Func<System.Reflection.TypeInfo, IEnumerable<T>> selector)
62 System.Reflection.TypeInfo ti = t.GetTypeInfo();
63 foreach (T f in selector(ti))