Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
EventInfo.cs
Go to the documentation of this file.
3
4namespace System.Reflection;
5
6public abstract class EventInfo : MemberInfo
7{
8 public override MemberTypes MemberType => MemberTypes.Event;
9
10 public abstract EventAttributes Attributes { get; }
11
12 public bool IsSpecialName => (Attributes & EventAttributes.SpecialName) != 0;
13
14 public virtual MethodInfo? AddMethod => GetAddMethod(nonPublic: true);
15
16 public virtual MethodInfo? RemoveMethod => GetRemoveMethod(nonPublic: true);
17
18 public virtual MethodInfo? RaiseMethod => GetRaiseMethod(nonPublic: true);
19
20 public virtual bool IsMulticast
21 {
22 get
23 {
24 Type eventHandlerType = EventHandlerType;
25 Type typeFromHandle = typeof(MulticastDelegate);
26 return typeFromHandle.IsAssignableFrom(eventHandlerType);
27 }
28 }
29
30 public virtual Type? EventHandlerType
31 {
32 get
33 {
34 MethodInfo addMethod = GetAddMethod(nonPublic: true);
35 ParameterInfo[] parametersNoCopy = addMethod.GetParametersNoCopy();
36 Type typeFromHandle = typeof(Delegate);
37 for (int i = 0; i < parametersNoCopy.Length; i++)
38 {
39 Type parameterType = parametersNoCopy[i].ParameterType;
40 if (parameterType.IsSubclassOf(typeFromHandle))
41 {
42 return parameterType;
43 }
44 }
45 return null;
46 }
47 }
48
50 {
51 return GetOtherMethods(nonPublic: false);
52 }
53
54 public virtual MethodInfo[] GetOtherMethods(bool nonPublic)
55 {
57 }
58
60 {
61 return GetAddMethod(nonPublic: false);
62 }
63
65 {
66 return GetRemoveMethod(nonPublic: false);
67 }
68
70 {
71 return GetRaiseMethod(nonPublic: false);
72 }
73
74 public abstract MethodInfo? GetAddMethod(bool nonPublic);
75
76 public abstract MethodInfo? GetRemoveMethod(bool nonPublic);
77
78 public abstract MethodInfo? GetRaiseMethod(bool nonPublic);
79
80 [DebuggerHidden]
81 [DebuggerStepThrough]
82 public virtual void AddEventHandler(object? target, Delegate? handler)
83 {
84 MethodInfo addMethod = GetAddMethod(nonPublic: false);
85 if (addMethod == null)
86 {
88 }
89 addMethod.Invoke(target, new object[1] { handler });
90 }
91
92 [DebuggerHidden]
93 [DebuggerStepThrough]
94 public virtual void RemoveEventHandler(object? target, Delegate? handler)
95 {
96 MethodInfo removeMethod = GetRemoveMethod(nonPublic: false);
97 if (removeMethod == null)
98 {
100 }
101 removeMethod.Invoke(target, new object[1] { handler });
102 }
103
104 public override bool Equals(object? obj)
105 {
106 return base.Equals(obj);
107 }
108
109 public override int GetHashCode()
110 {
111 return base.GetHashCode();
112 }
113
114 [MethodImpl(MethodImplOptions.AggressiveInlining)]
115 public static bool operator ==(EventInfo? left, EventInfo? right)
116 {
117 if ((object)right == null)
118 {
119 if ((object)left != null)
120 {
121 return false;
122 }
123 return true;
124 }
125 if ((object)left == right)
126 {
127 return true;
128 }
129 return left?.Equals(right) ?? false;
130 }
131
132 public static bool operator !=(EventInfo? left, EventInfo? right)
133 {
134 return !(left == right);
135 }
136}
static Exception ByDesign
MethodInfo? GetAddMethod()
Definition EventInfo.cs:59
static bool operator==(EventInfo? left, EventInfo? right)
Definition EventInfo.cs:115
MethodInfo? GetRemoveMethod(bool nonPublic)
virtual void AddEventHandler(object? target, Delegate? handler)
Definition EventInfo.cs:82
virtual ? MethodInfo RaiseMethod
Definition EventInfo.cs:18
override bool Equals(object? obj)
Definition EventInfo.cs:104
static bool operator!=(EventInfo? left, EventInfo? right)
Definition EventInfo.cs:132
MethodInfo? GetRaiseMethod()
Definition EventInfo.cs:69
override int GetHashCode()
Definition EventInfo.cs:109
MethodInfo[] GetOtherMethods()
Definition EventInfo.cs:49
MethodInfo? GetAddMethod(bool nonPublic)
MethodInfo? GetRaiseMethod(bool nonPublic)
EventAttributes Attributes
Definition EventInfo.cs:10
virtual ? Type EventHandlerType
Definition EventInfo.cs:31
virtual ? MethodInfo RemoveMethod
Definition EventInfo.cs:16
MethodInfo? GetRemoveMethod()
Definition EventInfo.cs:64
override MemberTypes MemberType
Definition EventInfo.cs:8
virtual void RemoveEventHandler(object? target, Delegate? handler)
Definition EventInfo.cs:94
virtual MethodInfo[] GetOtherMethods(bool nonPublic)
Definition EventInfo.cs:54
virtual ? MethodInfo AddMethod
Definition EventInfo.cs:14
object? Invoke(object? obj, object?[]? parameters)
virtual ParameterInfo[] GetParametersNoCopy()
static string InvalidOperation_NoPublicAddMethod
Definition SR.cs:1474
static string InvalidOperation_NoPublicRemoveMethod
Definition SR.cs:1476
Definition SR.cs:7
virtual bool IsAssignableFrom([NotNullWhen(true)] Type? c)
Definition Type.cs:1561
virtual bool IsSubclassOf(Type c)
Definition Type.cs:1542