Re: Looking to make something like a delegate...
- From: matsi.inc@xxxxxxxxx
- Date: 18 Jan 2007 12:21:58 -0800
Jon,
If I pass the delegate as a parameter then I cannot set the delegate's
parameter values. I would also have to pass an object array that
contains all the parameters and hope that they are in the correct
order, and the correct number of them.
Like...
cls2.MyMethod(myDel, new object[] { "How old are you?", 0 });
I have this working fine. But, you lose the benefit of intellisense
and making sure the parameters are typed and passed properly. That is
why i would like to be able to write...
cls2.MyMethod(myDel("How old are you?", 0));
What i want to do is just have the delegate functionality but when the
Invoke method is called, it does what I want it to do and not just
invoke the method the delegate is pointed to.
Make sense?
Jon Shemitz wrote:
matsi.inc@xxxxxxxxx wrote:
My ultimate goal is to be able to pass a method invocation as a
parameter without it being invoked. As an example...
... using the delegate above...
MyAssembly.MyClass cls = new MyAssembly.MyClass();
MyDelegate myDel = new MyDelegate(cls.targetMethod);
MyAssembly.MyClass2 cls2 = new MyAssembly.MyClass2();
cls2.MyMethod(myDel("How old are you?", 0));
When this is run, the MyMethod on cls2 will use reflection to determine
the origin of the delegate, extract the parameter values, and invoke
the method. This is what I would like to do.
Perhaps I'm missing something - why don't you just write cls2.MyMethod
to take a MyDelegate parameter?
--
.NET 2.0 for Delphi Programmers
www.midnightbeach.com/.net
.
- Follow-Ups:
- Re: Looking to make something like a delegate...
- From: Jon Shemitz
- Re: Looking to make something like a delegate...
- References:
- Looking to make something like a delegate...
- From: matsi . inc
- Re: Looking to make something like a delegate...
- From: Jon Shemitz
- Looking to make something like a delegate...
- Prev by Date: Non-locale-specific floating point numbers
- Next by Date: Re: Launch an app on logoff?
- Previous by thread: Re: Looking to make something like a delegate...
- Next by thread: Re: Looking to make something like a delegate...
- Index(es):
Relevant Pages
|