[Mono-list] Casting and Plugin Issue
Rodolfo Campero
rodolfocampero@hotmail.com
Sun, 27 Jun 2004 21:07:12 -0300
El dom, 27-06-2004 a las 20:17, Pablo Fischer escribi=F3:
> Hi!
>=20
> > Maybe you're compiling the source file where PostStruct is defined in
> > both assemblies, caller and callee. What you should do is to compile it
> > only in the caller, and then compile the plugin with a reference to the
> > caller assembly. Beware that you can't do this if the caller is an
> > "exe".
>=20
> Yeah, It works!. I compiled these *Struct.cs files as a Assembly (dll)
> and I'm compiling the plugin and main app with a reference to Struct.dll
> and it works!.
:) It feels nice to be helpful.
>=20
> > Maybe you could also add an interface, lets say IPlugin, which defines
> > the method GetPosts. This way you wouldn't have to use reflection in
> > order to invoke methods.
>=20
> Uhm, I did not understand very well this. In IPlugin.cs I have defined
> these methods (GetPost, GetPosts, etc) and in each Plugin I'm inheriting
> from it (IPlugin) so with the Wrapper I just call GetPost instead of
> calling each method with different names (Blogger, MetaWebLog,
> LiveJournal, etc). Or you have another idea? :-)
>=20
I don't have any other idea, but I thought that maybe instead of doing:
<snip>
my_method =3D t.GetMethod("MGetPosts");
object retVal =3D my_method.Invoke(activator,
BindingFlags.Instance |
BindingFlags.NonPublic |
BindingFlags.InvokeMethod,
null,
new Object[]{3, user},
null);
</snip>
You could do:
IPluging p =3D (IPlugin)t;
object retVal =3D p.MGetPosts(3, user);
> Thanks!!
> Pablo
Happy hacking,
Rodolfo