Re: Method info discovery using Reflection, variable argument list

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: JH (john_at_spamme.com)
Date: 09/22/04


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.



Relevant Pages

  • Re: Persistence
    ... Why do you think OODB never succeeded? ... flexible way rather than complex assemblies, ... can use the same data store to support alternate assemblies, ... objects implemented in a programming language to XML documents ...
    (comp.object)
  • Re: OleDb Connection to XML File
    ... This Job object could have a collection ... or writting Jobs as assemblies that the executing assembly dynamically loads ... connect to an XML file with OLE DB. ... would be best to store it in a database-like storage area. ...
    (microsoft.public.dotnet.framework.adonet)
  • Method info discovery using Reflection, variable argument list
    ... I'm developing a console app that loads dll assemblies at run time. ... static, a specific argument list(string, string, boolean)) then i store ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How to create a new object.
    ... If I store the fullName instead of Type itself it worked fine. ... Will loading all the assemblies before trying to create the object cause any ... "James Curran" wrote: ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Method info discovery using Reflection, variable argument list
    ... > I'm developing a console app that loads dll assemblies at run time. ... > static, a specific argument list(string, string, boolean)) then i store ... > e.g. string, string, boolean, int, int. ...
    (microsoft.public.dotnet.languages.csharp)