mscorlib(4.0.0.0) API with additions
System.Reflection.EventInfo Class Referenceabstract

Discovers the attributes of an event and provides access to event metadata. More...

Inheritance diagram for System.Reflection.EventInfo:
[legend]
Collaboration diagram for System.Reflection.EventInfo:
[legend]

Public Member Functions

override bool Equals (object obj)
 Returns a value that indicates whether this instance is equal to a specified object. More...
 
override int GetHashCode ()
 Returns the hash code for this instance. More...
 
virtual MethodInfo [] GetOtherMethods (bool nonPublic)
 Returns the methods that have been associated with the event in metadata using the .other directive, specifying whether to include non-public methods. More...
 
abstract MethodInfo GetAddMethod (bool nonPublic)
 When overridden in a derived class, retrieves the MethodInfo object for the M:System.Reflection.EventInfo.AddEventHandler(System.Object,System.Delegate) method of the event, specifying whether to return non-public methods. More...
 
abstract MethodInfo GetRemoveMethod (bool nonPublic)
 When overridden in a derived class, retrieves the MethodInfo object for removing a method of the event, specifying whether to return non-public methods. More...
 
abstract MethodInfo GetRaiseMethod (bool nonPublic)
 When overridden in a derived class, returns the method that is called when the event is raised, specifying whether to return non-public methods. More...
 
MethodInfo [] GetOtherMethods ()
 Returns the public methods that have been associated with an event in metadata using the .other directive. More...
 
MethodInfo GetAddMethod ()
 Returns the method used to add an event handler delegate to the event source. More...
 
MethodInfo GetRemoveMethod ()
 Returns the method used to remove an event handler delegate from the event source. More...
 
MethodInfo GetRaiseMethod ()
 Returns the method that is called when the event is raised. More...
 
virtual void AddEventHandler (object target, Delegate handler)
 Adds an event handler to an event source. More...
 
virtual void RemoveEventHandler (object target, Delegate handler)
 Removes an event handler from an event source. More...
 
- Public Member Functions inherited from System.Reflection.MemberInfo
abstract object [] GetCustomAttributes (bool inherit)
 When overridden in a derived class, returns an array of all custom attributes applied to this member. More...
 
abstract object [] GetCustomAttributes (Type attributeType, bool inherit)
 When overridden in a derived class, returns an array of custom attributes applied to this member and identified by T:System.Type. More...
 
abstract bool IsDefined (Type attributeType, bool inherit)
 When overridden in a derived class, indicates whether one or more attributes of the specified type or of its derived types is applied to this member. More...
 
virtual IList< CustomAttributeDataGetCustomAttributesData ()
 Returns a list of T:System.Reflection.CustomAttributeData objects representing data about the attributes that have been applied to the target member. More...
 
override bool Equals (object obj)
 Returns a value that indicates whether this instance is equal to a specified object. More...
 
override int GetHashCode ()
 Returns the hash code for this instance. More...
 
- Public Member Functions inherited from System.Runtime.InteropServices._MemberInfo
new string ToString ()
 Provides COM objects with version-independent access to the M:System.Object.ToString method. More...
 
- Public Member Functions inherited from System.Runtime.InteropServices._EventInfo
new string ToString ()
 Provides COM objects with version-independent access to the M:System.Object.ToString method. More...
 
object [] GetCustomAttributes (Type attributeType, bool inherit)
 Provides COM objects with version-independent access to the M:System.Reflection.MemberInfo.GetCustomAttributes(System.Type,System.Boolean) method. More...
 
object [] GetCustomAttributes (bool inherit)
 Provides COM objects with version-independent access to the M:System.Reflection.MemberInfo.GetCustomAttributes(System.Boolean) method. More...
 
bool IsDefined (Type attributeType, bool inherit)
 Provides COM objects with version-independent access to the M:System.Reflection.MemberInfo.IsDefined(System.Type,System.Boolean) method. More...
 

Static Public Member Functions

static bool operator== (EventInfo left, EventInfo right)
 Indicates whether two T:System.Reflection.EventInfo objects are equal. More...
 
static bool operator != (EventInfo left, EventInfo right)
 Indicates whether two T:System.Reflection.EventInfo objects are not equal. More...
 
- Static Public Member Functions inherited from System.Reflection.MemberInfo
static bool operator== (MemberInfo left, MemberInfo right)
 Indicates whether two T:System.Reflection.MemberInfo objects are equal. More...
 
static bool operator != (MemberInfo left, MemberInfo right)
 Indicates whether two T:System.Reflection.MemberInfo objects are not equal. More...
 

Public Attributes

override MemberTypes MemberType => MemberTypes.Event
 Gets a T:System.Reflection.MemberTypes value indicating that this member is an event. More...
 

Properties

abstract EventAttributes Attributes [get]
 Gets the attributes for this event. More...
 
virtual MethodInfo AddMethod [get]
 Gets the T:System.Reflection.MethodInfo object for the M:System.Reflection.EventInfo.AddEventHandler(System.Object,System.Delegate) method of the event, including non-public methods. More...
 
virtual MethodInfo RemoveMethod [get]
 Gets the MethodInfo object for removing a method of the event, including non-public methods. More...
 
virtual MethodInfo RaiseMethod [get]
 Gets the method that is called when the event is raised, including non-public methods. More...
 
virtual Type EventHandlerType [get]
 Gets the Type object of the underlying event-handler delegate associated with this event. More...
 
bool IsSpecialName [get]
 Gets a value indicating whether the EventInfo has a name with a special meaning. More...
 
virtual bool IsMulticast [get]
 Gets a value indicating whether the event is multicast. More...
 
- Properties inherited from System.Reflection.MemberInfo
abstract MemberTypes MemberType [get]
 When overridden in a derived class, gets a T:System.Reflection.MemberTypes value indicating the type of the member — method, constructor, event, and so on. More...
 
abstract string Name [get]
 Gets the name of the current member. More...
 
abstract Type DeclaringType [get]
 Gets the class that declares this member. More...
 
abstract Type ReflectedType [get]
 Gets the class object that was used to obtain this instance of MemberInfo. More...
 
virtual IEnumerable< CustomAttributeDataCustomAttributes [get]
 Gets a collection that contains this member's custom attributes. More...
 
virtual int MetadataToken [get]
 Gets a value that identifies a metadata element. More...
 
virtual Module Module [get]
 Gets the module in which the type that declares the member represented by the current T:System.Reflection.MemberInfo is defined. More...
 
- Properties inherited from System.Runtime.InteropServices._MemberInfo
MemberTypes MemberType [get]
 Provides COM objects with version-independent access to the P:System.Reflection.MemberInfo.MemberType property. More...
 
string Name [get]
 Provides COM objects with version-independent access to the P:System.Reflection.MemberInfo.Name property. More...
 
Type DeclaringType [get]
 Provides COM objects with version-independent access to the P:System.Reflection.MemberInfo.DeclaringType property. More...
 
Type ReflectedType [get]
 Provides COM objects with version-independent access to the P:System.Reflection.MemberInfo.ReflectedType property. More...
 
- Properties inherited from System.Runtime.InteropServices._EventInfo
MemberTypes MemberType [get]
 Provides COM objects with version-independent access to the P:System.Reflection.EventInfo.MemberType property. More...
 
string Name [get]
 Provides COM objects with version-independent access to the P:System.Reflection.MemberInfo.Name property. More...
 
Type DeclaringType [get]
 Provides COM objects with version-independent access to the P:System.Reflection.MemberInfo.DeclaringType property. More...
 
Type ReflectedType [get]
 Provides COM objects with version-independent access to the P:System.Reflection.MemberInfo.ReflectedType property. More...
 
EventAttributes Attributes [get]
 Provides COM objects with version-independent access to the P:System.Reflection.EventInfo.Attributes property. More...
 
Type EventHandlerType [get]
 Provides COM objects with version-independent access to the P:System.Reflection.EventInfo.EventHandlerType property. More...
 
bool IsSpecialName [get]
 Provides COM objects with version-independent access to the P:System.Reflection.EventInfo.IsSpecialName property. More...
 
bool IsMulticast [get]
 Provides COM objects with version-independent access to the P:System.Reflection.EventInfo.IsMulticast property. More...
 

Detailed Description

Discovers the attributes of an event and provides access to event metadata.

Definition at line 15 of file EventInfo.cs.

Member Function Documentation

◆ AddEventHandler()

virtual void System.Reflection.EventInfo.AddEventHandler ( object  target,
Delegate  handler 
)
virtual

Adds an event handler to an event source.

Parameters
targetThe event source.
handlerEncapsulates a method or methods to be invoked when the event is raised by the target.
Exceptions
T:System.InvalidOperationExceptionThe event does not have a public add accessor.
T:System.ArgumentExceptionThe handler that was passed in cannot be used.
T:System.MethodAccessExceptionIn the .NET for Windows Store apps or the Portable Class Library, catch the base class exception, T:System.MemberAccessException, instead.The caller does not have access permission to the member.
T:System.Reflection.TargetExceptionIn the .NET for Windows Store apps or the Portable Class Library, catch T:System.Exception instead.The target parameter is null and the event is not static.-or- The T:System.Reflection.EventInfo is not declared on the target.

Implements System.Runtime.InteropServices._EventInfo.

Reimplemented in System.Runtime.InteropServices.ComAwareEventInfo.

Definition at line 247 of file EventInfo.cs.

◆ Equals()

override bool System.Reflection.EventInfo.Equals ( object  obj)

Returns a value that indicates whether this instance is equal to a specified object.

Parameters
objAn object to compare with this instance, or null.
Returns
true if obj equals the type and value of this instance; otherwise, false.

Implements System.Runtime.InteropServices._EventInfo.

Definition at line 154 of file EventInfo.cs.

◆ GetAddMethod() [1/2]

abstract MethodInfo System.Reflection.EventInfo.GetAddMethod ( bool  nonPublic)
pure virtual

When overridden in a derived class, retrieves the MethodInfo object for the M:System.Reflection.EventInfo.AddEventHandler(System.Object,System.Delegate) method of the event, specifying whether to return non-public methods.

Parameters
nonPublictrue if non-public methods can be returned; otherwise, false.
Returns
A T:System.Reflection.MethodInfo object representing the method used to add an event handler delegate to the event source.
Exceptions
T:System.MethodAccessExceptionnonPublic is true, the method used to add an event handler delegate is non-public, and the caller does not have permission to reflect on non-public methods.

Implements System.Runtime.InteropServices._EventInfo.

Implemented in System.Runtime.InteropServices.ComAwareEventInfo.

◆ GetAddMethod() [2/2]

MethodInfo System.Reflection.EventInfo.GetAddMethod ( )

Returns the method used to add an event handler delegate to the event source.

Returns
A T:System.Reflection.MethodInfo object representing the method used to add an event handler delegate to the event source.

Implements System.Runtime.InteropServices._EventInfo.

Definition at line 214 of file EventInfo.cs.

◆ GetHashCode()

override int System.Reflection.EventInfo.GetHashCode ( )

Returns the hash code for this instance.

Returns
A 32-bit signed integer hash code.

Implements System.Runtime.InteropServices._EventInfo.

Definition at line 162 of file EventInfo.cs.

◆ GetOtherMethods() [1/2]

virtual MethodInfo [] System.Reflection.EventInfo.GetOtherMethods ( bool  nonPublic)
virtual

Returns the methods that have been associated with the event in metadata using the .other directive, specifying whether to include non-public methods.

Parameters
nonPublictrue to include non-public methods; otherwise, false.
Returns
An array of T:System.Reflection.EventInfo objects representing methods that have been associated with an event in metadata by using the .other directive. If there are no methods matching the specification, an empty array is returned.
Exceptions
T:System.NotImplementedExceptionThis method is not implemented.

Definition at line 172 of file EventInfo.cs.

◆ GetOtherMethods() [2/2]

MethodInfo [] System.Reflection.EventInfo.GetOtherMethods ( )

Returns the public methods that have been associated with an event in metadata using the .other directive.

Returns
An array of T:System.Reflection.EventInfo objects representing the public methods that have been associated with the event in metadata by using the .other directive. If there are no such public methods, an empty array is returned.

Definition at line 206 of file EventInfo.cs.

◆ GetRaiseMethod() [1/2]

abstract MethodInfo System.Reflection.EventInfo.GetRaiseMethod ( bool  nonPublic)
pure virtual

When overridden in a derived class, returns the method that is called when the event is raised, specifying whether to return non-public methods.

Parameters
nonPublictrue if non-public methods can be returned; otherwise, false.
Returns
A MethodInfo object that was called when the event was raised.
Exceptions
T:System.MethodAccessExceptionnonPublic is true, the method used to add an event handler delegate is non-public, and the caller does not have permission to reflect on non-public methods.

Implements System.Runtime.InteropServices._EventInfo.

Implemented in System.Runtime.InteropServices.ComAwareEventInfo.

◆ GetRaiseMethod() [2/2]

MethodInfo System.Reflection.EventInfo.GetRaiseMethod ( )

Returns the method that is called when the event is raised.

Returns
The method that is called when the event is raised.

Implements System.Runtime.InteropServices._EventInfo.

Definition at line 230 of file EventInfo.cs.

◆ GetRemoveMethod() [1/2]

abstract MethodInfo System.Reflection.EventInfo.GetRemoveMethod ( bool  nonPublic)
pure virtual

When overridden in a derived class, retrieves the MethodInfo object for removing a method of the event, specifying whether to return non-public methods.

Parameters
nonPublictrue if non-public methods can be returned; otherwise, false.
Returns
A T:System.Reflection.MethodInfo object representing the method used to remove an event handler delegate from the event source.
Exceptions
T:System.MethodAccessExceptionnonPublic is true, the method used to add an event handler delegate is non-public, and the caller does not have permission to reflect on non-public methods.

Implements System.Runtime.InteropServices._EventInfo.

Implemented in System.Runtime.InteropServices.ComAwareEventInfo.

◆ GetRemoveMethod() [2/2]

MethodInfo System.Reflection.EventInfo.GetRemoveMethod ( )

Returns the method used to remove an event handler delegate from the event source.

Returns
A T:System.Reflection.MethodInfo object representing the method used to remove an event handler delegate from the event source.

Implements System.Runtime.InteropServices._EventInfo.

Definition at line 222 of file EventInfo.cs.

◆ operator !=()

static bool System.Reflection.EventInfo.operator != ( EventInfo  left,
EventInfo  right 
)
static

Indicates whether two T:System.Reflection.EventInfo objects are not equal.

Parameters
leftThe first object to compare.
rightThe second object to compare.
Returns
true if left is not equal to right ; otherwise, false.

Definition at line 144 of file EventInfo.cs.

◆ operator==()

static bool System.Reflection.EventInfo.operator== ( EventInfo  left,
EventInfo  right 
)
static

Indicates whether two T:System.Reflection.EventInfo objects are equal.

Parameters
leftThe first object to compare.
rightThe second object to compare.
Returns
true if left is equal to right ; otherwise, false.

Definition at line 125 of file EventInfo.cs.

◆ RemoveEventHandler()

virtual void System.Reflection.EventInfo.RemoveEventHandler ( object  target,
Delegate  handler 
)
virtual

Removes an event handler from an event source.

Parameters
targetThe event source.
handlerThe delegate to be disassociated from the events raised by target.
Exceptions
T:System.InvalidOperationExceptionThe event does not have a public remove accessor.
T:System.ArgumentExceptionThe handler that was passed in cannot be used.
T:System.Reflection.TargetExceptionIn the .NET for Windows Store apps or the Portable Class Library, catch T:System.Exception instead.The target parameter is null and the event is not static.-or- The T:System.Reflection.EventInfo is not declared on the target.
T:System.MethodAccessExceptionIn the .NET for Windows Store apps or the Portable Class Library, catch the base class exception, T:System.MemberAccessException, instead.The caller does not have access permission to the member.

Implements System.Runtime.InteropServices._EventInfo.

Reimplemented in System.Runtime.InteropServices.ComAwareEventInfo.

Definition at line 276 of file EventInfo.cs.

Member Data Documentation

◆ MemberType

override MemberTypes System.Reflection.EventInfo.MemberType => MemberTypes.Event

Gets a T:System.Reflection.MemberTypes value indicating that this member is an event.

Returns
A T:System.Reflection.MemberTypes value indicating that this member is an event.

Definition at line 19 of file EventInfo.cs.

Property Documentation

◆ AddMethod

virtual MethodInfo System.Reflection.EventInfo.AddMethod
get

Gets the T:System.Reflection.MethodInfo object for the M:System.Reflection.EventInfo.AddEventHandler(System.Object,System.Delegate) method of the event, including non-public methods.

Returns
The T:System.Reflection.MethodInfo object for the M:System.Reflection.EventInfo.AddEventHandler(System.Object,System.Delegate) method.

Definition at line 34 of file EventInfo.cs.

◆ Attributes

abstract EventAttributes System.Reflection.EventInfo.Attributes
get

Gets the attributes for this event.

Returns
The read-only attributes for this event.

Definition at line 25 of file EventInfo.cs.

◆ EventHandlerType

virtual Type System.Reflection.EventInfo.EventHandlerType
get

Gets the Type object of the underlying event-handler delegate associated with this event.

Returns
A read-only Type object representing the delegate event handler.
Exceptions
T:System.Security.SecurityExceptionThe caller does not have the required permission.

Definition at line 71 of file EventInfo.cs.

◆ IsMulticast

virtual bool System.Reflection.EventInfo.IsMulticast
get

Gets a value indicating whether the event is multicast.

Returns
true if the delegate is an instance of a multicast delegate; otherwise, false.
Exceptions
T:System.Security.SecurityExceptionThe caller does not have the required permission.

Definition at line 109 of file EventInfo.cs.

◆ IsSpecialName

bool System.Reflection.EventInfo.IsSpecialName
get

Gets a value indicating whether the EventInfo has a name with a special meaning.

Returns
true if this event has a special name; otherwise, false.

Definition at line 95 of file EventInfo.cs.

◆ RaiseMethod

virtual MethodInfo System.Reflection.EventInfo.RaiseMethod
get

Gets the method that is called when the event is raised, including non-public methods.

Returns
The method that is called when the event is raised.

Definition at line 58 of file EventInfo.cs.

◆ RemoveMethod

virtual MethodInfo System.Reflection.EventInfo.RemoveMethod
get

Gets the MethodInfo object for removing a method of the event, including non-public methods.

Returns
The MethodInfo object for removing a method of the event.

Definition at line 46 of file EventInfo.cs.


The documentation for this class was generated from the following file: