2 // System.Reflection/EventInfo.cs
5 // Paolo Molaro (lupus@ximian.com)
7 // (C) 2001 Ximian, Inc. http://www.ximian.com
8 // Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 using System.Diagnostics;
31 using System.Runtime.InteropServices;
33 namespace System.Reflection {
37 [ComDefaultInterfaceAttribute (typeof (_EventInfo))]
40 [ClassInterface(ClassInterfaceType.None)]
41 public abstract class EventInfo : MemberInfo, _EventInfo {
43 public abstract EventAttributes Attributes {get;}
45 public Type EventHandlerType {
48 MethodInfo add = GetAddMethod (true);
49 p = add.GetParameters ();
51 Type t = p [0].ParameterType;
52 /* is it alwasys the first arg?
53 if (!t.IsSubclassOf (typeof (System.Delegate)))
54 throw new Exception ("no delegate in event");*/
60 public bool IsMulticast {get {return true;}}
61 public bool IsSpecialName {get {return (Attributes & EventAttributes.SpecialName ) != 0;}}
62 public override MemberTypes MemberType {
63 get {return MemberTypes.Event;}
66 protected EventInfo() {
70 public new Type GetType ()
72 return base.GetType ();
78 public void AddEventHandler (object target, Delegate handler)
80 MethodInfo add = GetAddMethod ();
82 throw new Exception ("No add method!?");
84 add.Invoke (target, new object [] {handler});
87 public MethodInfo GetAddMethod() {
88 return GetAddMethod (false);
90 public abstract MethodInfo GetAddMethod(bool nonPublic);
91 public MethodInfo GetRaiseMethod() {
92 return GetRaiseMethod (false);
94 public abstract MethodInfo GetRaiseMethod( bool nonPublic);
95 public MethodInfo GetRemoveMethod() {
96 return GetRemoveMethod (false);
98 public abstract MethodInfo GetRemoveMethod( bool nonPublic);
101 public virtual MethodInfo[] GetOtherMethods (bool nonPublic) {
102 // implemented by the derived class
103 return new MethodInfo [0];
106 public MethodInfo[] GetOtherMethods () {
107 return GetOtherMethods (false);
112 [DebuggerStepThrough]
113 public void RemoveEventHandler (object target, Delegate handler)
115 MethodInfo remove = GetRemoveMethod ();
117 throw new Exception ("No remove method!?");
119 remove.Invoke (target, new object [] {handler});
122 void _EventInfo.GetIDsOfNames ([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
124 throw new NotImplementedException ();
127 void _EventInfo.GetTypeInfo (uint iTInfo, uint lcid, IntPtr ppTInfo)
129 throw new NotImplementedException ();
132 void _EventInfo.GetTypeInfoCount (out uint pcTInfo)
134 throw new NotImplementedException ();
137 void _EventInfo.Invoke (uint dispIdMember, [In] ref Guid riid, uint lcid, short wFlags, IntPtr pDispParams, IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr)
139 throw new NotImplementedException ();