IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
GenericEventInfo.cs
Go to the documentation of this file.
1/*
2 Copyright (C) 2009, 2010 Jeroen Frijters
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19
20 Jeroen Frijters
21 jeroen@frijters.net
22
23*/
24namespace IKVM.Reflection
25{
26
27 sealed class GenericEventInfo : EventInfo
28 {
29
30 readonly Type typeInstance;
31 readonly EventInfo eventInfo;
32
38 internal GenericEventInfo(Type typeInstance, EventInfo eventInfo)
39 {
40 this.typeInstance = typeInstance;
41 this.eventInfo = eventInfo;
42 }
43
44 public override bool Equals(object obj)
45 {
46 var other = obj as GenericEventInfo;
47 return other != null && other.typeInstance == typeInstance && other.eventInfo == eventInfo;
48 }
49
50 public override int GetHashCode()
51 {
52 return typeInstance.GetHashCode() * 777 + eventInfo.GetHashCode();
53 }
54
55 public override EventAttributes Attributes
56 {
57 get { return eventInfo.Attributes; }
58 }
59
60 private MethodInfo Wrap(MethodInfo method)
61 {
62 if (method == null)
63 return null;
64
65 return new GenericMethodInstance(typeInstance, method, null);
66 }
67
68 public override MethodInfo GetAddMethod(bool nonPublic)
69 {
70 return Wrap(eventInfo.GetAddMethod(nonPublic));
71 }
72
73 public override MethodInfo GetRaiseMethod(bool nonPublic)
74 {
75 return Wrap(eventInfo.GetRaiseMethod(nonPublic));
76 }
77
78 public override MethodInfo GetRemoveMethod(bool nonPublic)
79 {
80 return Wrap(eventInfo.GetRemoveMethod(nonPublic));
81 }
82
83 public override MethodInfo[] GetOtherMethods(bool nonPublic)
84 {
85 var others = eventInfo.GetOtherMethods(nonPublic);
86 for (int i = 0; i < others.Length; i++)
87 others[i] = Wrap(others[i]);
88
89 return others;
90 }
91
92 public override MethodInfo[] __GetMethods()
93 {
94 var others = eventInfo.__GetMethods();
95 for (int i = 0; i < others.Length; i++)
96 others[i] = Wrap(others[i]);
97
98 return others;
99 }
100
101 public override Type EventHandlerType
102 {
103 get { return eventInfo.EventHandlerType.BindTypeParameters(typeInstance); }
104 }
105
106 public override string Name
107 {
108 get { return eventInfo.Name; }
109 }
110
111 public override Type DeclaringType
112 {
113 get { return typeInstance; }
114 }
115
116 public override Module Module
117 {
118 get { return eventInfo.Module; }
119 }
120
121 public override int MetadataToken
122 {
123 get { return eventInfo.MetadataToken; }
124 }
125
126 internal override EventInfo BindTypeParameters(Type type)
127 {
128 return new GenericEventInfo(typeInstance.BindTypeParameters(type), eventInfo);
129 }
130
131 internal override bool IsPublic
132 {
133 get { return eventInfo.IsPublic; }
134 }
135
136 internal override bool IsNonPrivate
137 {
138 get { return eventInfo.IsNonPrivate; }
139 }
140
141 internal override bool IsStatic
142 {
143 get { return eventInfo.IsStatic; }
144 }
145
146 internal override bool IsBaked
147 {
148 get { return eventInfo.IsBaked; }
149 }
150
151 internal override int GetCurrentToken()
152 {
153 return eventInfo.GetCurrentToken();
154 }
155
156 }
157
158}
global::java.lang.invoke.LambdaForm.Name Name
override MethodInfo GetRaiseMethod(bool nonPublic)
override MethodInfo GetRemoveMethod(bool nonPublic)
override bool Equals(object obj)
override MethodInfo GetAddMethod(bool nonPublic)
override MethodInfo[] __GetMethods()
override MethodInfo[] GetOtherMethods(bool nonPublic)
override EventAttributes Attributes