BK
Mon Sep 15 08:35:18 CDT 2003
Yes, I tried this, but there is no way to get the value of event delegate.
"Eric Gunnerson [MS]" <ericgu@online.microsoft.com> wrote in message
news:#nKaIileDHA.1836@TK2MSFTNGP09.phx.gbl...
> Sure:
>
> Type type = typeof (YourClassName); // can use
instance.GetType()
> as well.
>
> foreach (MemberInfo memberInfo in type.GetMembers())
> {
> if (memberInfo.MemberType == MemberType.Event)
>
> // and then you use MemberType to get the value here. It will probably
> come back as as a delegate (I'm not sure).
> }
>
> Hope that helps.
>
>
>
> --
> Eric Gunnerson
>
> Visit the C# product team at
http://www.csharp.net
> Eric's blog is at
http://blogs.gotdotnet.com/ericgu/
>
> This posting is provided "AS IS" with no warranties, and confers no
rights.
> "BK" <bluekiteNO-SPAM@rogers.com> wrote in message
> news:eGq6N8WeDHA.696@TK2MSFTNGP09.phx.gbl...
> > Hi,
> >
> > I have a class which has a lot of events (>100). For some reasons, I
have
> to
> > go through all invocation lists to do something. What I'm wondering is
> that,
> > is there any way to use reflection to get their InvocationList without
> going
> > through each event?
> >
> > // tedious
> > foreach (Delegate handler in Event1.GetInvocationList()) {...}
> > foreach (Delegate handler in Event2.GetInvocationList()) {...}
> > foreach (Delegate handler in Event3.GetInvocationList()) {...}
> > ...
> > foreach (Delegate handler in Event189.GetInvocationList()) {...}
> >
> > // user reflection???
> > ....
> >
> > Looks like this is a hard question as I haven't googled any answers.
> Thanks
> >
> > BK
> >
> >
>
>