2 // System.Reflection/EventInfo.cs
5 // Paolo Molaro (lupus@ximian.com)
7 // (C) 2001 Ximian, Inc. http://www.ximian.com
11 using System.Reflection;
13 namespace System.Reflection {
14 public abstract class EventInfo : MemberInfo {
16 public abstract EventAttributes Attributes {get;}
18 public Type EventHandlerType {
21 MethodInfo add = GetAddMethod (true);
22 p = add.GetParameters ();
24 Type t = p [0].ParameterType;
25 /* is it alwasys the first arg?
26 if (!t.IsSubclassOf (typeof (System.Delegate)))
27 throw new Exception ("no delegate in event");*/
33 public bool IsMulticast {get {return true;}}
34 public bool IsSpecialName {get {return (Attributes & EventAttributes.SpecialName ) != 0;}}
35 public override MemberTypes MemberType {
36 get {return MemberTypes.Event;}
39 protected EventInfo() {
42 public void AddEventHandler (object target, Delegate handler)
44 MethodInfo add = GetAddMethod ();
46 throw new Exception ("No add method!?");
48 add.Invoke (target, new object [] {handler});
51 public MethodInfo GetAddMethod() {
52 return GetAddMethod (false);
54 public abstract MethodInfo GetAddMethod(bool nonPublic);
55 public MethodInfo GetRaiseMethod() {
56 return GetRaiseMethod (false);
58 public abstract MethodInfo GetRaiseMethod( bool nonPublic);
59 public MethodInfo GetRemoveMethod() {
60 return GetRemoveMethod (false);
62 public abstract MethodInfo GetRemoveMethod( bool nonPublic);
64 public void RemoveEventHandler (object target, Delegate handler)
66 MethodInfo remove = GetRemoveMethod ();
68 throw new Exception ("No remove method!?");
70 remove.Invoke (target, new object [] {handler});
73 public override bool IsDefined (Type attributeType, bool inherit) {
74 return MonoCustomAttrs.IsDefined (this, attributeType, inherit);
77 public override object[] GetCustomAttributes( bool inherit) {
78 return MonoCustomAttrs.GetCustomAttributes (this, inherit);
80 public override object[] GetCustomAttributes( Type attributeType, bool inherit) {
81 return MonoCustomAttrs.GetCustomAttributes (this, attributeType, inherit);
83 public override Type ReflectedType {
88 public override Type DeclaringType {
94 public override String Name {