[Kde-bindings] Qyoto: SIGNALS/SLOTS

Richard Dale Richard_Dale at tipitina.demon.co.uk
Tue Dec 13 21:01:57 UTC 2005


On Tuesday 13 December 2005 18:23, Arno Rehn wrote:
> Am Dienstag, 13. Dezember 2005 18:53 schrieb Richard Dale:
> > On Monday 12 December 2005 20:05, Arno Rehn wrote:
> > > Am Montag, 12. Dezember 2005 18:01 schrieb Richard Dale:
> > > > 		// Which reflection method can be used to get the parent interface
> > > > 		// of IQApplicationSignals, so it doesn't need to be hard coded
> > > > 		// as IQObjectSignals like here?
> > > > 		miSignal = typeof(IQObjectSignals).GetMethod("Destroyed");
> > > > 		attributes = miSignal.GetCustomAttributes(typeof(Q_SIGNAL), false);
> > > > 		if (attributes.Length > 0) {
> > > > 			Q_SIGNAL signalAttr = (Q_SIGNAL) attributes[0];
> > > > 			Console.WriteLine( "Q_SIGNAL signature: {0}", signalAttr.Signature
> > > > ); }
> > >
> > > Try this:
> > >
> > >  		miSignal =
> > > typeof(IQApplicationSignals).BaseType.GetMethod("Destroyed");	//with
> > > 'BaseType' you get the first type that the current type is derived from
> > >  		attributes = miSignal.GetCustomAttributes(typeof(Q_SIGNAL), false);
> > >  		if (attributes.Length > 0) {
> > >  			Q_SIGNAL signalAttr = (Q_SIGNAL) attributes[0];
> > >  			Console.WriteLine( "Q_SIGNAL signature: {0}", signalAttr.Signature
> > > ); }
> >
> > I've just been trying this and I get a null returned by
> > typeof(IQApplicationSignals).BaseType. Is that because interfaces can
> > have more than one BaseType? Is there a BaseTypes attribute for
> > interfaces that returns an Array of types?
>
> Or try 'typeof(IQApplicationSignals).GetInterfaces()'. this should work
> really.
After a bit of messing around with casts, this one works:

		Object interfaceType = typeof(IQApplicationSignals).GetInterfaces();
        Console.WriteLine( "interfaceType: {0}", interfaceType );            

        miSignal = ((Type[]) interfaceType)[0].GetMethod("Destroyed");   
        attributes = miSignal.GetCustomAttributes(typeof(Q_SIGNAL), false);
        if (attributes.Length > 0) {
                        Q_SIGNAL signalAttr = (Q_SIGNAL) attributes[0];
                        Console.WriteLine( "Q_SIGNAL signature: {0}", 
signalAttr.Signature );
        }

-- Richard



More information about the Kde-bindings mailing list