static GLib.Value ParseProperty(Type type, bool childprop, string name, string strval) { ParamSpec pspec; // FIXME: this can be removed when GParamSpec supports ValueType. PropertyInfo pi = FindClrProperty(type, name, childprop); if (pi == null) { throw new GladeException("Unknown property", type.ToString(), childprop, name, strval); } if (childprop) { pspec = ParamSpec.LookupChildProperty(type, name); } else { pspec = ParamSpec.LookupObjectProperty(type, name); } if (pspec == null) { throw new GladeException("Unknown property", type.ToString(), childprop, name, strval); } try { return(ParseProperty(pspec, pi.PropertyType, strval)); } catch { throw new GladeException("Could not parse property", type.ToString(), childprop, name, strval); } }
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); }