ParamSpec FindPSpec(PropertyInfo pinfo) { foreach (object attr in pinfo.GetCustomAttributes(false)) { if (attr is GLib.PropertyAttribute) { GLib.PropertyAttribute pattr = (GLib.PropertyAttribute)attr; return(ParamSpec.LookupObjectProperty(pinfo.DeclaringType, pattr.Name)); } if (attr is Gtk.ChildPropertyAttribute) { Gtk.ChildPropertyAttribute cpattr = (Gtk.ChildPropertyAttribute)attr; return(ParamSpec.LookupChildProperty(pinfo.DeclaringType.DeclaringType, cpattr.Name)); } } return(null); }
static PropertyInfo FindClrProperty(Type type, string name, bool childprop) { if (childprop) { Type[] types = type.GetNestedTypes(); foreach (Type t in types) { if (typeof(Gtk.Container.ContainerChild).IsAssignableFrom(t)) { type = t; break; } } foreach (PropertyInfo pi in type.GetProperties()) { Gtk.ChildPropertyAttribute at = (Gtk.ChildPropertyAttribute)Attribute.GetCustomAttribute(pi, typeof(Gtk.ChildPropertyAttribute), false); if (at != null && at.Name == name) { return(pi); } } if (typeof(GLib.Object).IsAssignableFrom(type.BaseType)) { return(FindClrProperty(type.BaseType, name, true)); } } foreach (PropertyInfo pi in type.GetProperties()) { GLib.PropertyAttribute at = (GLib.PropertyAttribute)Attribute.GetCustomAttribute(pi, typeof(GLib.PropertyAttribute), false); if (at != null && at.Name == name) { return(pi); } } return(null); }