[Gtk-sharp-list] g_signal_connect_data flags again
   
    Gonzalo Paniagua Javier
     
    gonzalo@ximian.com
       
    15 Mar 2003 22:40:57 +0100
    
    
  
--=-O6+7oTmVsvFaw9dk+zsm
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
El sáb, 15 de 03 de 2003 a las 22:10, Miguel de Icaza escribió:
> > And how do you get that attribute from the delegate?
> 
> You fetch the Invoke method from the delegate, fetch the MethodInfo,
> retrieve the custom attributes.
That works for the simplest case:
Delegate d = new EventHandler (MyMethod);
obj.evnt += d;
but if you do:
Delegate d = new EventHandler (MyMethod);
d = Delegate.Combine (d, new EventHandler (OtherMethod));
it does not work.
I've attached a test case.
-Gonzalo
-- 
"The wireless telegraph is not dificult to understand. The ordinary
telegraph is like a very long cat. You pull the tail in New York and it
meows in Los Angeles. The wireless is the same, only without the cat"
					-Albert
--=-O6+7oTmVsvFaw9dk+zsm
Content-Disposition: attachment; filename=migattr.cs
Content-Type: text/plain; name=migattr.cs; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
using System;
using System.Reflection;
class AfterAttribute : Attribute
{
}
class MigAttr
{
	[After]
	public static void MyMethod (object o, EventArgs args)
	{
	}
	
	public static void OtherMethod (object o, EventArgs args)
	{
	}
	static void Main ()
	{
		Type t = typeof (MigAttr);
		Delegate d = new EventHandler (MyMethod);
		d = Delegate.Combine (d, new EventHandler (OtherMethod));
		MethodInfo m = t.GetMethod ("MyMethod");
		foreach (Attribute attr in m.GetCustomAttributes (false))
			Console.WriteLine (attr);
		m = d.Method;
		foreach (Attribute attr in m.GetCustomAttributes (false))
			Console.WriteLine (attr);
	}
}
--=-O6+7oTmVsvFaw9dk+zsm--