Re: Method info discovery using Reflection, variable argument list
From: JH (john_at_spamme.com)
Date: 09/22/04
- Next message: Ahmad Raza: "Re: XML from J#"
- Previous message: Viktor Popov: "Repeater paging problem"
- In reply to: Jon Skeet [C# MVP]: "Re: Method info discovery using Reflection, variable argument list"
- Next in thread: Jon Skeet [C# MVP]: "Re: Method info discovery using Reflection, variable argument list"
- Reply: Jon Skeet [C# MVP]: "Re: Method info discovery using Reflection, variable argument list"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 22 Sep 2004 11:58:25 +0100
"Jon Skeet [C# MVP]" <skeet@pobox.com> wrote in message
news:MPG.1bbb6552bc1c7a0898b4ab@msnews.microsoft.com...
> JH <john@spamme.com> wrote:
> > Fairly new to c# so please forgive any simple oversights.
> >
> > I'm developing a console app that loads dll assemblies at run time. The
app
> > scans a "plugin" directory for these dlls. Each dll is loaded into an
> > Assembly object, the types in the assembly are extracted and the methods
on
> > each type are extracted. If a method matches certain criteria (i.e.
public
> > static, a specific argument list(string, string, boolean)) then i store
> > details about the method. Any method "matches" that are found will be
> > invoked at a later time.
> >
> > My problem is that while most of these "target" methods will have the
same
> > argument list (string,string,boolean) some may have additonal parameters
> > e.g. string, string, boolean, int, int. I also need to store these new
> > methods and if possible i will need to get some information on the new
> > parameters to identify them to the user i.e. parameter name.
> >
> > Is what i describe about the variable arguments possible to do? if so
how?
> > Thanks in advance for any help provided.
>
> Yes, all of that is possible. Which part are you having trouble with?
> The code you gave showed that you know about ParameterInfo - that has
> the type and the name.
>
> Btw, I would suggest using typeof(...) rather than Type.GetType(...)
> for types you know about in advance.
>
Cheers Jon,
I think i know what to do now, i just had some mental block about variable
parameter lists (memories from my C days!).
If i check for methods with a minimum of three parameters that match the
spec then i store the method name. I will also store the ParamTypes array
with the method name, so at a later stage i can itterate through the array
and present the user with the names of any additional parameters. Then i can
invoke the method. Seems reasonable enough.
- Next message: Ahmad Raza: "Re: XML from J#"
- Previous message: Viktor Popov: "Repeater paging problem"
- In reply to: Jon Skeet [C# MVP]: "Re: Method info discovery using Reflection, variable argument list"
- Next in thread: Jon Skeet [C# MVP]: "Re: Method info discovery using Reflection, variable argument list"
- Reply: Jon Skeet [C# MVP]: "Re: Method info discovery using Reflection, variable argument list"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|