mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2025-03-01 10:27:09 +00:00
2008-01-24 Lluis Sanchez Gual <lluis@novell.com>
* glade/XML.custom: due to a recent Mono fix (bug #322762), Type.GetFields does not return private fields from base classes anymore, so the BindFields now has to go through the class hierarchy to get all fields. svn path=/trunk/gtk-sharp/; revision=93742
This commit is contained in:
parent
a1b5081559
commit
b40365eafb
|
@ -1,3 +1,10 @@
|
||||||
|
2008-01-24 Lluis Sanchez Gual <lluis@novell.com>
|
||||||
|
|
||||||
|
* glade/XML.custom: due to a recent Mono fix (bug #322762),
|
||||||
|
Type.GetFields does not return private fields from base classes
|
||||||
|
anymore, so the BindFields now has to go through the class
|
||||||
|
hierarchy to get all fields.
|
||||||
|
|
||||||
2008-01-23 Mike Kestner <mkestner@novell.com>
|
2008-01-23 Mike Kestner <mkestner@novell.com>
|
||||||
|
|
||||||
* bootstrap-2.12: update version and tag 2.11.91.
|
* bootstrap-2.12: update version and tag 2.11.91.
|
||||||
|
|
|
@ -352,38 +352,42 @@
|
||||||
|
|
||||||
private void BindFields (object target, Type type)
|
private void BindFields (object target, Type type)
|
||||||
{
|
{
|
||||||
System.Reflection.BindingFlags flags = System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic;
|
System.Reflection.BindingFlags flags = System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.DeclaredOnly;
|
||||||
if (target != null)
|
if (target != null)
|
||||||
flags |= System.Reflection.BindingFlags.Instance;
|
flags |= System.Reflection.BindingFlags.Instance;
|
||||||
else
|
else
|
||||||
flags |= System.Reflection.BindingFlags.Static;
|
flags |= System.Reflection.BindingFlags.Static;
|
||||||
|
|
||||||
System.Reflection.FieldInfo[] fields = type.GetFields (flags);
|
do {
|
||||||
if (fields == null)
|
System.Reflection.FieldInfo[] fields = type.GetFields (flags);
|
||||||
return;
|
if (fields == null)
|
||||||
|
return;
|
||||||
|
|
||||||
foreach (System.Reflection.FieldInfo field in fields)
|
foreach (System.Reflection.FieldInfo field in fields)
|
||||||
{
|
{
|
||||||
object[] attrs = field.GetCustomAttributes (typeof (WidgetAttribute), false);
|
object[] attrs = field.GetCustomAttributes (typeof (WidgetAttribute), false);
|
||||||
if (attrs == null || attrs.Length == 0)
|
if (attrs == null || attrs.Length == 0)
|
||||||
continue;
|
continue;
|
||||||
// The widget to field binding must be 1:1, so only check
|
// The widget to field binding must be 1:1, so only check
|
||||||
// the first attribute.
|
// the first attribute.
|
||||||
WidgetAttribute attr = (WidgetAttribute) attrs[0];
|
WidgetAttribute attr = (WidgetAttribute) attrs[0];
|
||||||
Gtk.Widget widget;
|
Gtk.Widget widget;
|
||||||
if (attr.Specified)
|
if (attr.Specified)
|
||||||
widget = GetWidget (attr.Name);
|
widget = GetWidget (attr.Name);
|
||||||
else
|
else
|
||||||
widget = GetWidget (field.Name);
|
widget = GetWidget (field.Name);
|
||||||
|
|
||||||
if (widget != null)
|
if (widget != null)
|
||||||
try {
|
try {
|
||||||
field.SetValue (target, widget, flags, null, null);
|
field.SetValue (target, widget, flags, null, null);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Console.WriteLine ("Unable to set value for field " + field.Name);
|
Console.WriteLine ("Unable to set value for field " + field.Name);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
type = type.BaseType;
|
||||||
}
|
}
|
||||||
|
while (type != typeof(object) && type != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BindFields (object target)
|
public void BindFields (object target)
|
||||||
|
|
Loading…
Reference in a new issue