473,668 Members | 2,265 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1754
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******@hotma il.com> wrote in message
news:e7******** *************** ***@posting.goo gle.com...
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.

[FriendlyDescrip tion("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******** ******@TK2MSFTN GP12.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******@hotma il.com> wrote in message
news:e7******** *************** ***@posting.goo gle.com...
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******* *******@TK2MSFT NGP12.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******@hotma il.com> wrote in message
news:e7******** *************** ***@posting.goo gle.com...

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******* *******@TK2MSFT NGP11.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******* *******@TK2MSFT NGP11.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******@hotma il.com> wrote in message
news:e7******** *************** ***@posting.goo gle.com...
"Daniel Bass" <I'm really @ sick of spam> wrote in message
news:<#f******* *******@TK2MSFT NGP11.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

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

Similar topics

99
5881
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 important changes, so in this thread I would like to focus on that issue alone. I have edited the Proposed Syntax example below to take out the changes unecessary to this discussion. I left in the change of "instance variable" syntax (...
1
2535
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 good uses for this?!!). How do I do this for an event on a class I implement? Also, how may I do this for an event in the .Net framework e.g. a control?
4
1549
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 etc. But as far as I can see many of the methods aint ever used. Is there a way to traverse the layer and name methods that never called from any location in the source code?
4
2188
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 inherit my base page class (which in turn inherits System.Web.UI.Page). Behold the following code: For Each asm As System.Reflection.Assembly In System.AppDomain.CurrentDomain.GetAssemblies() For Each mdl As System.Reflection.Module In...
9
4723
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 assembly. The reason for this is that I want to check some attributes of all child classes and have the base class react to this information in the child classes. Is this possible in an easy way, or do I have to traverse all loaded assemblies and...
4
4113
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 use a Factory to create them all in a generic way. The problem is that if I create a IMyInterface - I cannot access the derived UserControl Methods. I need to access the Methods derived from UserControl and also the Interface
8
12233
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
866
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 be more explicit lets take an example. Having the following methods in a class: public void UpdateMyStuff(string data) { //transform input data and call the private method UpdatePrivately(transformedData); }
3
4828
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, due to a couple limitations of the language, MI is still not attainable (at least not succinctly). 1 - Interfaces cannot define data (only properties) 2 - Extension methods cannot be used to mix in property definitions (or implement interface...
0
8459
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8374
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8791
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8575
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8653
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7398
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6206
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5677
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4373
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.