Files
2026-06-04 11:42:34 +02:00

325 lines
16 KiB
C#

using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace System.Reflection
{
/// <summary>Discovers the attributes of an event and provides access to event metadata.</summary>
// Token: 0x0200023E RID: 574
[ComVisible(true)]
[ComDefaultInterface(typeof(_EventInfo))]
[ClassInterface(ClassInterfaceType.None)]
[Serializable]
public abstract class EventInfo : MemberInfo, _EventInfo
{
/// <summary>Maps a set of names to a corresponding set of dispatch identifiers.</summary>
/// <param name="riid">Reserved for future use. Must be IID_NULL.</param>
/// <param name="rgszNames">Passed-in array of names to be mapped.</param>
/// <param name="cNames">Count of the names to be mapped.</param>
/// <param name="lcid">The locale context in which to interpret the names.</param>
/// <param name="rgDispId">Caller-allocated array which receives the IDs corresponding to the names.</param>
/// <exception cref="T:System.NotImplementedException">Late-bound access using the COM IDispatch interface is not supported.</exception>
// Token: 0x06001DF6 RID: 7670 RVA: 0x000703A4 File Offset: 0x0006E5A4
void _EventInfo.GetIDsOfNames([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
{
throw new NotImplementedException();
}
/// <summary>Retrieves the type information for an object, which can then be used to get the type information for an interface.</summary>
/// <param name="iTInfo">The type information to return.</param>
/// <param name="lcid">The locale identifier for the type information.</param>
/// <param name="ppTInfo">Receives a pointer to the requested type information object.</param>
/// <exception cref="T:System.NotImplementedException">Late-bound access using the COM IDispatch interface is not supported.</exception>
// Token: 0x06001DF7 RID: 7671 RVA: 0x000703AC File Offset: 0x0006E5AC
void _EventInfo.GetTypeInfo(uint iTInfo, uint lcid, IntPtr ppTInfo)
{
throw new NotImplementedException();
}
/// <summary>Retrieves the number of type information interfaces that an object provides (either 0 or 1).</summary>
/// <param name="pcTInfo">Points to a location that receives the number of type information interfaces provided by the object.</param>
/// <exception cref="T:System.NotImplementedException">Late-bound access using the COM IDispatch interface is not supported.</exception>
// Token: 0x06001DF8 RID: 7672 RVA: 0x000703B4 File Offset: 0x0006E5B4
void _EventInfo.GetTypeInfoCount(out uint pcTInfo)
{
throw new NotImplementedException();
}
/// <summary>Provides access to properties and methods exposed by an object.</summary>
/// <param name="dispIdMember">Identifies the member.</param>
/// <param name="riid">Reserved for future use. Must be IID_NULL.</param>
/// <param name="lcid">The locale context in which to interpret arguments.</param>
/// <param name="wFlags">Flags describing the context of the call.</param>
/// <param name="pDispParams">Pointer to a structure containing an array of arguments, an array of argument DISPIDs for named arguments, and counts for the number of elements in the arrays.</param>
/// <param name="pVarResult">Pointer to the location where the result is to be stored.</param>
/// <param name="pExcepInfo">Pointer to a structure that contains exception information.</param>
/// <param name="puArgErr">The index of the first argument that has an error.</param>
/// <exception cref="T:System.NotImplementedException">Late-bound access using the COM IDispatch interface is not supported.</exception>
// Token: 0x06001DF9 RID: 7673 RVA: 0x000703BC File Offset: 0x0006E5BC
void _EventInfo.Invoke(uint dispIdMember, [In] ref Guid riid, uint lcid, short wFlags, IntPtr pDispParams, IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr)
{
throw new NotImplementedException();
}
/// <summary>Gets the attributes for this event.</summary>
/// <returns>The read-only attributes for this event.</returns>
// Token: 0x17000565 RID: 1381
// (get) Token: 0x06001DFA RID: 7674
public abstract EventAttributes Attributes { get; }
/// <summary>Gets the Type object of the underlying event-handler delegate associated with this event.</summary>
/// <returns>A read-only Type object representing the delegate event handler.</returns>
/// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission. </exception>
// Token: 0x17000566 RID: 1382
// (get) Token: 0x06001DFB RID: 7675 RVA: 0x000703C4 File Offset: 0x0006E5C4
public Type EventHandlerType
{
get
{
MethodInfo addMethod = this.GetAddMethod(true);
ParameterInfo[] parameters = addMethod.GetParameters();
if (parameters.Length > 0)
{
return parameters[0].ParameterType;
}
return null;
}
}
/// <summary>Gets a value indicating whether the event is multicast.</summary>
/// <returns>true if the delegate is an instance of a multicast delegate; otherwise, false.</returns>
/// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission. </exception>
// Token: 0x17000567 RID: 1383
// (get) Token: 0x06001DFC RID: 7676 RVA: 0x000703F8 File Offset: 0x0006E5F8
public bool IsMulticast
{
get
{
return true;
}
}
/// <summary>Gets a value indicating whether the EventInfo has a name with a special meaning.</summary>
/// <returns>true if this event has a special name; otherwise, false.</returns>
// Token: 0x17000568 RID: 1384
// (get) Token: 0x06001DFD RID: 7677 RVA: 0x000703FC File Offset: 0x0006E5FC
public bool IsSpecialName
{
get
{
return (this.Attributes & EventAttributes.SpecialName) != EventAttributes.None;
}
}
/// <summary>Gets a <see cref="T:System.Reflection.MemberTypes" /> value indicating that this member is an event.</summary>
/// <returns>A <see cref="T:System.Reflection.MemberTypes" /> value indicating that this member is an event.</returns>
// Token: 0x17000569 RID: 1385
// (get) Token: 0x06001DFE RID: 7678 RVA: 0x00070410 File Offset: 0x0006E610
public override MemberTypes MemberType
{
get
{
return MemberTypes.Event;
}
}
/// <summary>Adds an event handler to an event source.</summary>
/// <param name="target">The event source. </param>
/// <param name="handler">Encapsulates a method or methods to be invoked when the event is raised by the target. </param>
/// <exception cref="T:System.InvalidOperationException">The event does not have a public add accessor.</exception>
/// <exception cref="T:System.ArgumentException">The handler that was passed in cannot be used. </exception>
/// <exception cref="T:System.MethodAccessException">The caller does not have access permission to the member. </exception>
/// <exception cref="T:System.Reflection.TargetException">The <paramref name="target" /> parameter is null and the event is not static.-or- The <see cref="T:System.Reflection.EventInfo" /> is not declared on the target. </exception>
// Token: 0x06001DFF RID: 7679 RVA: 0x00070414 File Offset: 0x0006E614
[DebuggerStepThrough]
[DebuggerHidden]
public void AddEventHandler(object target, Delegate handler)
{
if (this.cached_add_event == null)
{
MethodInfo addMethod = this.GetAddMethod();
if (addMethod == null)
{
throw new InvalidOperationException("Cannot add a handler to an event that doesn't have a visible add method");
}
if (addMethod.DeclaringType.IsValueType)
{
if (target == null && !addMethod.IsStatic)
{
throw new TargetException("Cannot add a handler to a non static event with a null target");
}
addMethod.Invoke(target, new object[] { handler });
return;
}
else
{
this.cached_add_event = EventInfo.CreateAddEventDelegate(addMethod);
}
}
this.cached_add_event(target, handler);
}
/// <summary>Returns the method used to add an event handler delegate to the event source.</summary>
/// <returns>A <see cref="T:System.Reflection.MethodInfo" /> object representing the method used to add an event handler delegate to the event source.</returns>
// Token: 0x06001E00 RID: 7680 RVA: 0x0007049C File Offset: 0x0006E69C
public MethodInfo GetAddMethod()
{
return this.GetAddMethod(false);
}
/// <summary>When overridden in a derived class, retrieves the MethodInfo object for the <see cref="M:System.Reflection.EventInfo.AddEventHandler(System.Object,System.Delegate)" /> method of the event, specifying whether to return non-public methods.</summary>
/// <returns>A <see cref="T:System.Reflection.MethodInfo" /> object representing the method used to add an event handler delegate to the event source.</returns>
/// <param name="nonPublic">true if non-public methods can be returned; otherwise, false. </param>
/// <exception cref="T:System.MethodAccessException">
/// <paramref name="nonPublic" /> 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. </exception>
// Token: 0x06001E01 RID: 7681
public abstract MethodInfo GetAddMethod(bool nonPublic);
/// <summary>Returns the method that is called when the event is raised.</summary>
/// <returns>The method that is called when the event is raised.</returns>
// Token: 0x06001E02 RID: 7682 RVA: 0x000704A8 File Offset: 0x0006E6A8
public MethodInfo GetRaiseMethod()
{
return this.GetRaiseMethod(false);
}
/// <summary>When overridden in a derived class, returns the method that is called when the event is raised, specifying whether to return non-public methods.</summary>
/// <returns>A MethodInfo object that was called when the event was raised.</returns>
/// <param name="nonPublic">true if non-public methods can be returned; otherwise, false. </param>
/// <exception cref="T:System.MethodAccessException">
/// <paramref name="nonPublic" /> 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. </exception>
// Token: 0x06001E03 RID: 7683
public abstract MethodInfo GetRaiseMethod(bool nonPublic);
/// <summary>Returns the method used to remove an event handler delegate from the event source.</summary>
/// <returns>A <see cref="T:System.Reflection.MethodInfo" /> object representing the method used to remove an event handler delegate from the event source.</returns>
// Token: 0x06001E04 RID: 7684 RVA: 0x000704B4 File Offset: 0x0006E6B4
public MethodInfo GetRemoveMethod()
{
return this.GetRemoveMethod(false);
}
/// <summary>When overridden in a derived class, retrieves the MethodInfo object for removing a method of the event, specifying whether to return non-public methods.</summary>
/// <returns>A <see cref="T:System.Reflection.MethodInfo" /> object representing the method used to remove an event handler delegate from the event source.</returns>
/// <param name="nonPublic">true if non-public methods can be returned; otherwise, false. </param>
/// <exception cref="T:System.MethodAccessException">
/// <paramref name="nonPublic" /> 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. </exception>
// Token: 0x06001E05 RID: 7685
public abstract MethodInfo GetRemoveMethod(bool nonPublic);
/// <summary>Returns the methods that have been associated with the event in metadata using the .other directive, specifying whether to include non-public methods.</summary>
/// <returns>An array of <see cref="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.</returns>
/// <param name="nonPublic">true to include non-public methods; otherwise, false.</param>
/// <exception cref="T:System.NotImplementedException">This method is not implemented.</exception>
// Token: 0x06001E06 RID: 7686 RVA: 0x000704C0 File Offset: 0x0006E6C0
public virtual MethodInfo[] GetOtherMethods(bool nonPublic)
{
return new MethodInfo[0];
}
/// <summary>Returns the public methods that have been associated with an event in metadata using the .other directive.</summary>
/// <returns>An array of <see cref="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.</returns>
// Token: 0x06001E07 RID: 7687 RVA: 0x000704C8 File Offset: 0x0006E6C8
public MethodInfo[] GetOtherMethods()
{
return this.GetOtherMethods(false);
}
/// <summary>Removes an event handler from an event source.</summary>
/// <param name="target">The event source. </param>
/// <param name="handler">The delegate to be disassociated from the events raised by target. </param>
/// <exception cref="T:System.InvalidOperationException">The event does not have a public remove accessor. </exception>
/// <exception cref="T:System.ArgumentException">The handler that was passed in cannot be used. </exception>
/// <exception cref="T:System.Reflection.TargetException">The <paramref name="target" /> parameter is null and the event is not static.-or- The <see cref="T:System.Reflection.EventInfo" /> is not declared on the target. </exception>
/// <exception cref="T:System.MethodAccessException">The caller does not have access permission to the member. </exception>
// Token: 0x06001E08 RID: 7688 RVA: 0x000704D4 File Offset: 0x0006E6D4
[DebuggerStepThrough]
[DebuggerHidden]
public void RemoveEventHandler(object target, Delegate handler)
{
MethodInfo removeMethod = this.GetRemoveMethod();
if (removeMethod == null)
{
throw new InvalidOperationException("Cannot remove a handler to an event that doesn't have a visible remove method");
}
removeMethod.Invoke(target, new object[] { handler });
}
// Token: 0x06001E09 RID: 7689 RVA: 0x0007050C File Offset: 0x0006E70C
private static void AddEventFrame<T, D>(EventInfo.AddEvent<T, D> addEvent, object obj, object dele)
{
if (obj == null)
{
throw new TargetException("Cannot add a handler to a non static event with a null target");
}
if (!(obj is T))
{
throw new TargetException("Object doesn't match target");
}
addEvent((T)((object)obj), (D)((object)dele));
}
// Token: 0x06001E0A RID: 7690 RVA: 0x00070548 File Offset: 0x0006E748
private static void StaticAddEventAdapterFrame<D>(EventInfo.StaticAddEvent<D> addEvent, object obj, object dele)
{
addEvent((D)((object)dele));
}
// Token: 0x06001E0B RID: 7691 RVA: 0x00070558 File Offset: 0x0006E758
private static EventInfo.AddEventAdapter CreateAddEventDelegate(MethodInfo method)
{
Type[] array;
Type type;
string text;
if (method.IsStatic)
{
array = new Type[] { method.GetParameters()[0].ParameterType };
type = typeof(EventInfo.StaticAddEvent<>);
text = "StaticAddEventAdapterFrame";
}
else
{
array = new Type[]
{
method.DeclaringType,
method.GetParameters()[0].ParameterType
};
type = typeof(EventInfo.AddEvent<, >);
text = "AddEventFrame";
}
Type type2 = type.MakeGenericType(array);
object obj = Delegate.CreateDelegate(type2, method, false);
if (obj == null)
{
throw new MethodAccessException();
}
MethodInfo methodInfo = typeof(EventInfo).GetMethod(text, BindingFlags.Static | BindingFlags.NonPublic);
methodInfo = methodInfo.MakeGenericMethod(array);
return (EventInfo.AddEventAdapter)Delegate.CreateDelegate(typeof(EventInfo.AddEventAdapter), obj, methodInfo, true);
}
/// <summary>Returns a T:System.Type object representing the <see cref="T:System.Reflection.EventInfo" /> type.</summary>
/// <returns>A T:System.Type object representing the <see cref="T:System.Reflection.EventInfo" /> type.</returns>
// Token: 0x06001E0C RID: 7692 RVA: 0x00070624 File Offset: 0x0006E824
virtual Type System.Runtime.InteropServices._EventInfo.GetType()
{
return base.GetType();
}
// Token: 0x04000A2D RID: 2605
private EventInfo.AddEventAdapter cached_add_event;
// Token: 0x020006C9 RID: 1737
// (Invoke) Token: 0x060041AC RID: 16812
private delegate void AddEventAdapter(object _this, Delegate dele);
// Token: 0x020006CA RID: 1738
// (Invoke) Token: 0x060041B0 RID: 16816
private delegate void AddEvent<T, D>(T _this, D dele);
// Token: 0x020006CB RID: 1739
// (Invoke) Token: 0x060041B4 RID: 16820
private delegate void StaticAddEvent<D>(D dele);
}
}