473,321 Members | 1,916 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

Finding Methods using Reflection

Ian
Hi, I am writing an application and am creating a plug-in interface
for it.

The application will need to 'find' the plug-in's and will then need
to find all accessible methods.

The corresponding methods will need to have a corresponding 'user
friendly' name.

Eg: public void goForward() {...} will need to have a user friendly
name of "Go Forward"

I was thinking of creating an enumeration of custom objects (or maybe
string arrays ) that will store both the method name (for reflection)
and the associated friendly name.

This however seems a bit clunky. Am I on the right track or is there
any better way to do this?
Nov 15 '05 #1
11 1732
Ian,

The idea behind plug-in architecture is that you have one interface, from
which all plugins must derive, and then instantiate. Your calling program
will then know what methods are available, and what to do with them.

This way all a program needs to know is the location of the plugin (easy if
you just enumerate through the .DLL files in a plugin folder say), then call
the methods on the interface, and let the plugin do it's thing.

Does that make sense?

I've got some code you can look at if you like...
http://www.dunesand.com/blog/developer/developer.htm

let me know if you need any more help with that.

Later.
Dan.

"Ian" <he******@hotmail.com> wrote in message
news:e7**************************@posting.google.c om...
Hi, I am writing an application and am creating a plug-in interface
for it.

The application will need to 'find' the plug-in's and will then need
to find all accessible methods.

The corresponding methods will need to have a corresponding 'user
friendly' name.

Eg: public void goForward() {...} will need to have a user friendly
name of "Go Forward"

I was thinking of creating an enumeration of custom objects (or maybe
string arrays ) that will store both the method name (for reflection)
and the associated friendly name.

This however seems a bit clunky. Am I on the right track or is there
any better way to do this?
Nov 15 '05 #2
If you have a function in your interface that has a generic sounding name,
e.g. DoWork()
You could create an attribute that can be used to supply a more meaningful
name.
The value of this attribute can be determined at runtime.

[FriendlyDescription("This operation creates a fuzzy warm feeling while you
wait")]
public void DoWork()
{
}
Chris

"Daniel Bass" <I'm really @ sick of spam> wrote in message
news:O4**************@TK2MSFTNGP12.phx.gbl...
Ian,

The idea behind plug-in architecture is that you have one interface, from
which all plugins must derive, and then instantiate. Your calling program
will then know what methods are available, and what to do with them.

This way all a program needs to know is the location of the plugin (easy if you just enumerate through the .DLL files in a plugin folder say), then call the methods on the interface, and let the plugin do it's thing.

Does that make sense?

I've got some code you can look at if you like...
http://www.dunesand.com/blog/developer/developer.htm

let me know if you need any more help with that.

Later.
Dan.

"Ian" <he******@hotmail.com> wrote in message
news:e7**************************@posting.google.c om...
Hi, I am writing an application and am creating a plug-in interface
for it.

The application will need to 'find' the plug-in's and will then need
to find all accessible methods.

The corresponding methods will need to have a corresponding 'user
friendly' name.

Eg: public void goForward() {...} will need to have a user friendly
name of "Go Forward"

I was thinking of creating an enumeration of custom objects (or maybe
string arrays ) that will store both the method name (for reflection)
and the associated friendly name.

This however seems a bit clunky. Am I on the right track or is there
any better way to do this?

Nov 15 '05 #3
Ian
"Daniel Bass" <I'm really @ sick of spam> wrote in message news:<O4**************@TK2MSFTNGP12.phx.gbl>...
Ian,

The idea behind plug-in architecture is that you have one interface, from
which all plugins must derive, and then instantiate. Your calling program
will then know what methods are available, and what to do with them.

This way all a program needs to know is the location of the plugin (easy if
you just enumerate through the .DLL files in a plugin folder say), then call
the methods on the interface, and let the plugin do it's thing.

Does that make sense?

I've got some code you can look at if you like...
http://www.dunesand.com/blog/developer/developer.htm

let me know if you need any more help with that.

Later.
Dan.


Thanks for that Dan, I gave that some thought, but soon dismissed it
as I won't know what functions the 3rd party developer is going to use
- and they need that flexibility.

Looking at your code however has given me a couple of ideas, it may
actually be the path to head down.

Ian.
Nov 15 '05 #4
Ian,

Why is that? I ask because this really breaks the whole idea of having an
OOD.
What's your scenario that this would not work in?

Later.
Dan.

"Ian" <he******@hotmail.com> wrote in message
news:e7**************************@posting.google.c om...

Thanks for that Dan, I gave that some thought, but soon dismissed it
as I won't know what functions the 3rd party developer is going to use
- and they need that flexibility.

Looking at your code however has given me a couple of ideas, it may
actually be the path to head down.

Ian.
Nov 15 '05 #5
Ian
"Daniel Bass" <I'm really @ sick of spam> wrote in message news:<#f**************@TK2MSFTNGP11.phx.gbl>...
Ian,

Why is that? I ask because this really breaks the whole idea of having an
OOD.
What's your scenario that this would not work in?

Later.
Dan.


I am a great fan of using interfaces - I've come from a Java
background where they're used extensively. I also believe they would
work very well in my situation.

The reason I initially dismissed it was I thought it would be more
..netish(?) to not restrict the 3rd party plug-in developer into using
c#. A more appropriate option would be COM (wouldn't it?). Based on my
knowledge (albeit very little in the grand scheme) of .net, an
interface wouldn't work in this scenario. Please feel free to correct
me.

Due to my limited knowlege and my want to get something developed
ASAP, I am now starting to believe it would be better to focus on
using interfaces and restricting the plug-in developer to using c#.
Nov 15 '05 #6
Ian
"Daniel Bass" <I'm really @ sick of spam> wrote in message news:<#f**************@TK2MSFTNGP11.phx.gbl>...
Ian,

Why is that? I ask because this really breaks the whole idea of having an
OOD.
What's your scenario that this would not work in?

Later.
Dan.


Giving it even more thought (brain about to pop), COM support is prob
a bad idea in total. .net support however is possibly a good idea.
That way, if a user want's to use vb or c++ they can. Would this (from
what I can tell - inexperience is now glowing brightly) affect me
using interfaces?
Nov 15 '05 #7
Ian wrote:
Due to my limited knowlege and my want to get something developed
ASAP, I am now starting to believe it would be better to focus on
using interfaces and restricting the plug-in developer to using c#.


If your code is CLS compliant, the end user can consume your components in
any .NET language.

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
(Pull the pin to reply)
Nov 15 '05 #8
This may also be helpful:

http://www.geocities.com/jeff_louie/OOP/oop13.htm

Regards,
Jeff

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #9
COM is also based on the interfaces concept...
The host needs to know what to call on the plugin, either way.

..Net is great for this sort of thing. If you're not sure the plugins will
only be using .Net, then create a .Net plugin that is a COM proxy, which
will then allow others to use the native COM interface if they wish. I've
recently done this and it all works really well.

If you unsure about all this, make sure you sit down and plan it first. It's
something that requires design and thought before just going at it.

Good luck!

Dan.

"Ian" <he******@hotmail.com> wrote in message
news:e7**************************@posting.google.c om...
"Daniel Bass" <I'm really @ sick of spam> wrote in message
news:<#f**************@TK2MSFTNGP11.phx.gbl>...
Ian,

Why is that? I ask because this really breaks the whole idea of having an
OOD.
What's your scenario that this would not work in?

Later.
Dan.


Giving it even more thought (brain about to pop), COM support is prob
a bad idea in total. .net support however is possibly a good idea.
That way, if a user want's to use vb or c++ they can. Would this (from
what I can tell - inexperience is now glowing brightly) affect me
using interfaces?
Nov 15 '05 #10
Ian,
I dont think by choosing interfaces you would be restricting people to
C#. VB.net and J# all support interfaces. Also, even COM implementations
of plug-ins use a form of contracts. Essentially the host application
looks through the interfaces in the typelib to determine if certain
methods are implemented. the VS environement uses(d) IConnectedDb (not
to sure of the name, its been a while) for the plug-ins to connect to
the environment.
Also as an additional comment, the plug-in by defenition must
operate in the confines/ contracts of the host application as opposed to
doing its own thing and expecting the host application to manage it
nevertheless.

Ian wrote:
"Daniel Bass" <I'm really @ sick of spam> wrote in message news:<#f**************@TK2MSFTNGP11.phx.gbl>...
Ian,

Why is that? I ask because this really breaks the whole idea of having an
OOD.
What's your scenario that this would not work in?

Later.
Dan.

I am a great fan of using interfaces - I've come from a Java
background where they're used extensively. I also believe they would
work very well in my situation.

The reason I initially dismissed it was I thought it would be more
..netish(?) to not restrict the 3rd party plug-in developer into using
c#. A more appropriate option would be COM (wouldn't it?). Based on my
knowledge (albeit very little in the grand scheme) of .net, an
interface wouldn't work in this scenario. Please feel free to correct
me.

Due to my limited knowlege and my want to get something developed
ASAP, I am now starting to believe it would be better to focus on
using interfaces and restricting the plug-in developer to using c#.


--
Regards,
Dilip Krishnan
MCAD, MCSD.net
dilipdotnet at apdiya dot com
Nov 15 '05 #11
Ian
Thanks everyone for your help. I've received some serious pointers here. :)
Nov 15 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

99
by: David MacQuigg | last post by:
I'm not getting any feedback on the most important benefit in my proposed "Ideas for Python 3" thread - the unification of methods and functions. Perhaps it was buried among too many other less...
1
by: emma middlebrook | last post by:
Hi I want to find out what objects are due to receive an event i.e. those that have added themselves as an event handler via +=. Yes, it's a little pointless perhaps (or can anyone give some...
4
by: Anders K. Jacobsen [DK] | last post by:
Hey I have been givin the job the extend an asp.net c# application with and extensive but very poor documented business layer. There are aprox 1200 methods like: FindAvailAmount, GetAllEmployee...
4
by: Per Bolmstedt | last post by:
(This question has been asked previously in this group, but I don't think it was ever really properly answered.) I want to use reflection - preferably - to find all Web Forms in my web site that...
9
by: Allan Ebdrup | last post by:
I would like to use reflection to find all classes that inherit from my current class, even if they are in another assembly I want to find them if the current project has a reference to that...
4
by: =?Utf-8?B?c2lwcHl1Y29ubg==?= | last post by:
Hi I have a user control that is designed as below. I am creating these User Controls Dynamically in another form. They are multiple types of User Controls all with a common Interface so I can...
8
by: Frank Rizzo | last post by:
Is there a setting in VS2005 to quickly locate methods that are unused (maybe through compiler warnings)? If not, any utilities out there that do that? Thanks
0
by: csharpuser | last post by:
Does anybody know how to disallow the direct invokation of a private method using reflection but still allow the invokation through reflection of a public method which uses the private method. To...
3
by: johanatan | last post by:
When I first heard about these new features, I was very excited as it would have (if implemented as I had expected) rendered mimicking multiple inheritance almost painless in C#. Unfortunately,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.