2 // System.Reflection/EventInfo.cs
5 // Paolo Molaro (lupus@ximian.com)
7 // (C) 2001 Ximian, Inc. http://www.ximian.com
11 using System.Reflection;
12 using System.Runtime.InteropServices;
14 namespace System.Reflection {
16 [ClassInterface(ClassInterfaceType.AutoDual)]
17 public abstract class EventInfo : MemberInfo {
19 public abstract EventAttributes Attributes {get;}
21 public Type EventHandlerType {
24 MethodInfo add = GetAddMethod (true);
25 p = add.GetParameters ();
27 Type t = p [0].ParameterType;
28 /* is it alwasys the first arg?
29 if (!t.IsSubclassOf (typeof (System.Delegate)))
30 throw new Exception ("no delegate in event");*/
36 public bool IsMulticast {get {return true;}}
37 public bool IsSpecialName {get {return (Attributes & EventAttributes.SpecialName ) != 0;}}
38 public override MemberTypes MemberType {
39 get {return MemberTypes.Event;}
42 protected EventInfo() {
45 public void AddEventHandler (object target, Delegate handler)
47 MethodInfo add = GetAddMethod ();
49 throw new Exception ("No add method!?");
51 add.Invoke (target, new object [] {handler});
54 public MethodInfo GetAddMethod() {
55 return GetAddMethod (false);
57 public abstract MethodInfo GetAddMethod(bool nonPublic);
58 public MethodInfo GetRaiseMethod() {
59 return GetRaiseMethod (false);
61 public abstract MethodInfo GetRaiseMethod( bool nonPublic);
62 public MethodInfo GetRemoveMethod() {
63 return GetRemoveMethod (false);
65 public abstract MethodInfo GetRemoveMethod( bool nonPublic);
67 public void RemoveEventHandler (object target, Delegate handler)
69 MethodInfo remove = GetRemoveMethod ();
71 throw new Exception ("No remove method!?");
73 remove.Invoke (target, new object [] {handler});
76 public override bool IsDefined (Type attributeType, bool inherit) {
77 return MonoCustomAttrs.IsDefined (this, attributeType, inherit);
80 public override object[] GetCustomAttributes( bool inherit) {
81 return MonoCustomAttrs.GetCustomAttributes (this, inherit);
83 public override object[] GetCustomAttributes( Type attributeType, bool inherit) {
84 return MonoCustomAttrs.GetCustomAttributes (this, attributeType, inherit);
86 public override Type ReflectedType {
91 public override Type DeclaringType {
97 public override String Name {