473,320 Members | 2,024 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,320 software developers and data experts.

plz help on delegates

4
I need anyone's help!!! i have to build a list of methods that will be available for decoupled components to add and call functions from another components, so far i am using delegates to add methods to the list, but delegates ask me to state the type of parameters that each method has, and i want the list to accept any kind of method regarding the signaturei want to be able to do this:

class1{
List methods;
methods.add(int index, Method method) //Method can be other than Delegate, i don't mind
{ .... }
}
class2{
class1.methods.add(1,M1);
class2.methods.add(2,M2);
class3.methods.add(3,M3);

void M1(string g){...}
void M2(int f, int w){ .. }
void M3() { ... }
}

class3{
class1.call(1);
class1.call(3);
}

please please please!!! somebody?? anybody??
Jan 25 '07 #1
3 1040
enreil
86
I don't know a whole lot about using delegates, but can't you just have them accept parameters of type Object or Object(), depending on whether you want to pass single or multiple parameters?

I need anyone's help!!! i have to build a list of methods that will be available for decoupled components to add and call functions from another components, so far i am using delegates to add methods to the list, but delegates ask me to state the type of parameters that each method has, and i want the list to accept any kind of method regarding the signaturei want to be able to do this:

class1{
List methods;
methods.add(int index, Method method) //Method can be other than Delegate, i don't mind
{ .... }
}
class2{
class1.methods.add(1,M1);
class2.methods.add(2,M2);
class3.methods.add(3,M3);

void M1(string g){...}
void M2(int f, int w){ .. }
void M3() { ... }
}

class3{
class1.call(1);
class1.call(3);
}

please please please!!! somebody?? anybody??
Jan 25 '07 #2
Motoma
3,237 Expert 2GB
I need anyone's help!!! i have to build a list of methods that will be available for decoupled components to add and call functions from another components, so far i am using delegates to add methods to the list, but delegates ask me to state the type of parameters that each method has, and i want the list to accept any kind of method regarding the signaturei want to be able to do this:

class1{
List methods;
methods.add(int index, Method method) //Method can be other than Delegate, i don't mind
{ .... }
}
class2{
class1.methods.add(1,M1);
class2.methods.add(2,M2);
class3.methods.add(3,M3);

void M1(string g){...}
void M2(int f, int w){ .. }
void M3() { ... }
}

class3{
class1.call(1);
class1.call(3);
}

please please please!!! somebody?? anybody??
Why do you need to use only one delegate?
Couldn't you declare three delegates, and for each different set of arguments?
If you could overload delegates, then you would only ever need one.
Jan 26 '07 #3
rox59
4
Why do you need to use only one delegate?
Couldn't you declare three delegates, and for each different set of arguments?
If you could overload delegates, then you would only ever need one.
Thanks for your posts, I kind of solved it by storing an object of type Method in the methods list with the constructor

Expand|Select|Wrap|Line Numbers
  1. Method(string name , Type[] argsTypesType instanceType)
the argsTypes is not really necessary if you are not overloading methods within the same component which is not my case :(

the list only holds those attributes and when i want to call the method from another component I use another function in my Method class that basically does this:

Expand|Select|Wrap|Line Numbers
  1. instanceType.InvokeMember(name, BindingFlags.InvokeMethod, null, instance, userParameters);
i get the instance object from an inner list that has all executing component instances
Jan 26 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Jeffrey T. Smith | last post by:
Back when the new J2SE1.5 features were announced, there was a JavaLive community chat (http://java.sun.com/developer/community/chat/JavaLive/2003/jl0729.html) in which Neal Gafter explains the...
3
by: Sam | last post by:
I’m just starting to learn delegates. I’m at the very beginning. If I understand correctly, delegates are for when you want to pass a function as a parameter. For example the client provides a...
4
by: LP | last post by:
Hello! I am still transitioning from VB.NET to C#. I undertand the basic concepts of Delegates, more so of Events and somewhat understand AsyncCallback methods. But I need some clarification on...
4
by: AMDRIT | last post by:
I am trying to understand Delegates and where/when to use them. I can see one potential use of a delegate (on form closing, set the cancel property in the event arguments.) Does anyone have a...
6
by: =?Utf-8?B?Sko=?= | last post by:
I have a logger component that logs to multiple sources, ie textfile, eventlog etc. and I have two methods that depending on where I call up my logger comp. one of them will be called. For ex. if...
0
by: bharathreddy | last post by:
Delegates Here in this article I will explain about delegates in brief. Some important points about delegates. This article is meant to only those who already know delegates, it will be a quick...
6
by: =?Utf-8?B?T2xkQ2FEb2c=?= | last post by:
My question is regarding the use of delegates in C#. I see how .Net uses delegates to wire event handlers to events. It’s an object created by a single line of code by the system and that makes...
7
by: Siegfried Heintze | last post by:
I'm studying the book "Microsoft Visual Basic.NET Language Reference" and I would like some clarify the difference between events and delegates. On page 156 I see a WinForms example of timer that...
69
by: raylopez99 | last post by:
They usually don't teach you in most textbooks I've seen that delegates can be used to call class methods from classes that are 'unaware' of the delegate, so long as the class has the same...
9
by: raylopez99 | last post by:
Hello all— I’m trying to get the below to work and cannot get the format right. It’s from this example: http://msdn.microsoft.com/en-us/library/8627sbea(VS.71).aspx What it is: I’m trying...
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
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)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.