IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
MemberInfo.cs
Go to the documentation of this file.
1/*
2 Copyright (C) 2009 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*/
24
25using System;
26using System.Collections.Generic;
27
28namespace IKVM.Reflection
29{
30
31 // disable warnings that complain about us having == and != operators without also overriding Equals/GetHashCode,
32 // this is intentional because most subtypes use reference equality
33#pragma warning disable 660, 661
34 internal abstract class MemberInfo : ICustomAttributeProvider
35 {
36
40 internal MemberInfo()
41 {
42
43 }
44
45 public abstract string Name { get; }
46
47 public abstract Type DeclaringType { get; }
48
49 public abstract MemberTypes MemberType { get; }
50
51 public virtual Type ReflectedType
52 {
53 get { return DeclaringType; }
54 }
55
56 internal abstract MemberInfo SetReflectedType(Type type);
57
58 public virtual int MetadataToken
59 {
60 get { throw new NotSupportedException(); }
61 }
62
63 public abstract Module Module
64 {
65 get;
66 }
67
68 public virtual bool __IsMissing
69 {
70 get { return false; }
71 }
72
73 public bool IsDefined(Type attributeType, bool inherit)
74 {
75 return CustomAttributeData.__GetCustomAttributes(this, attributeType, inherit).Count != 0;
76 }
77
78 public IList<CustomAttributeData> __GetCustomAttributes(Type attributeType, bool inherit)
79 {
80 return CustomAttributeData.__GetCustomAttributes(this, attributeType, inherit);
81 }
82
83 public IList<CustomAttributeData> GetCustomAttributesData()
84 {
85 return CustomAttributeData.GetCustomAttributes(this);
86 }
87
88 public IEnumerable<CustomAttributeData> CustomAttributes
89 {
90 get { return GetCustomAttributesData(); }
91 }
92
93 public static bool operator ==(MemberInfo m1, MemberInfo m2)
94 {
95 return ReferenceEquals(m1, m2) || (!ReferenceEquals(m1, null) && m1.Equals(m2));
96 }
97
98 public static bool operator !=(MemberInfo m1, MemberInfo m2)
99 {
100 return !(m1 == m2);
101 }
102
103 internal abstract int GetCurrentToken();
104
105 internal abstract List<CustomAttributeData> GetPseudoCustomAttributes(Type attributeType);
106
107 internal abstract bool IsBaked { get; }
108
109 internal virtual bool BindingFlagsMatch(BindingFlags flags)
110 {
111 throw new InvalidOperationException();
112 }
113
114 internal virtual bool BindingFlagsMatchInherited(BindingFlags flags)
115 {
116 throw new InvalidOperationException();
117 }
118
119 protected static bool BindingFlagsMatch(bool state, BindingFlags flags, BindingFlags trueFlag, BindingFlags falseFlag)
120 {
121 return (state && (flags & trueFlag) == trueFlag) || (!state && (flags & falseFlag) == falseFlag);
122 }
123
124 protected static T SetReflectedType<T>(T member, Type type)
125 where T : MemberInfo
126 {
127 return member == null ? null : (T)member.SetReflectedType(type);
128 }
129
130 protected static T[] SetReflectedType<T>(T[] members, Type type)
131 where T : MemberInfo
132 {
133 for (int i = 0; i < members.Length; i++)
134 members[i] = SetReflectedType(members[i], type);
135
136 return members;
137 }
138
139 }
140
141}
IKVM.Reflection.Module Module
IKVM.Reflection.Type Type
IKVM.Reflection.MemberInfo MemberInfo
global::java.lang.invoke.LambdaForm.Name Name