Then do your hook before you call the delegate. Then call the delegate.
Maybe you could expand on what your asking.
--
William Stacey [C# MVP]
<ma*******@gmail.comwrote in message
news:11*********************@11g2000cwr.googlegrou ps.com...
| Stoitcho,
|
| Thanks for the information. I took a look at the generics and they
| don't really solve my problem of what I am wanting to do. I may be
| being picky here, but it just seems that I should be able to mimic the
| behavior of anything provided in the framework exactly. What I like
| about the delegate is that no matter how many parameters you define the
| delegate with, the Invoke method matches those parameters. What i do
| not like, is when you call Invoke, it automatically calls the target
| method with the supplied parameter values. What i want to do is
| intercept this invocation and do something else with the information
| provided by the delegate invocation (method and parameter values). So,
| i dont really want a delegate, but i want something that behaves like
| one.
|
| Any ideas?
|
| Stoitcho Goutsev (100) wrote:
| Hi,
| >
| when you declare a delegate the compiler actually generates a new class
that
| inherits from the MulticastDelegate class (which inherits from Delegate)
and
| declares the Invoke method with desired signature.
| >
| If by locked you mean sealed then no, neither Delegate nor
MulticastDelegate
| or the compiler generated class is not sealed. The only think is that
you
| cannot use them as a base class because the compiler doesn't allow you
to.
| The compiler allows you only to use its syntax for declaring delegates.
On
| the other hands for more configurable delegates you can use generics -
| Generic Delegates.
| >
| For more info look at:
|
http://msdn2.microsoft.com/en-us/lib...w7(VS.80).aspx
| >
| >
| --
| HTH
| Stoitcho Goutsev (100)
| >
| <ma*******@gmail.comwrote in message
| news:11**********************@s34g2000cwa.googlegr oups.com...
| I am looking to make something like a delegate that i can use in my
| projects but am having a hard time getting started.
|
| The behavior I am most interested in is how a delegate changes it's
| Invoke method dynamically to match the arguments supplied to it when
it
| is defined. For example...
|
|
| public delegate void MyDelegate(string myString, int myInt);
|
| MyDelegate myDel = new MyDelegate(my.Target);
|
|
| When I look at the Invoke method for myDel, you see...
|
| myDel.Invoke(string myString, int myInt);
|
| What I am ultimately looking to do is override the Invoke method of a
| delegate but being that the Delegate class is locked, I can't just do
| it the easy way.
|
| 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.
|
| Even to understand/learn how a delegate definition allows for a
| variable number of parameters to be defined, and then turn around and
| create an Invoke method on the delegate that matches these parameters
| would be a great deal of help.
|
| Any help, suggestions, alternatives would be greatly appreciated.
|
|