IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
IKVM.Reflection.DefaultBinder Class Referencesealed

Public Member Functions

override MethodBase SelectMethod (BindingFlags bindingAttr, MethodBase[] match, Type[] types, ParameterModifier[] modifiers)
 
override PropertyInfo SelectProperty (BindingFlags bindingAttr, PropertyInfo[] match, Type returnType, Type[] indexes, ParameterModifier[] modifiers)
 

Detailed Description

Definition at line 29 of file DefaultBinder.cs.

Member Function Documentation

◆ SelectMethod()

override MethodBase IKVM.Reflection.DefaultBinder.SelectMethod ( BindingFlags bindingAttr,
MethodBase[] match,
Type[] types,
ParameterModifier[] modifiers )

Definition at line 32 of file DefaultBinder.cs.

33 {
34 var matchCount = 0;
35 foreach (var method in match)
36 if (MatchParameterTypes(method.GetParameters(), types))
37 match[matchCount++] = method;
38
39 if (matchCount == 0)
40 return null;
41
42 var bestMatch = match[0];
43 var ambiguous = false;
44 for (int i = 1; i < matchCount; i++)
45 SelectBestMatch(match[i], types, ref bestMatch, ref ambiguous);
46
47 if (ambiguous)
48 throw new AmbiguousMatchException();
49
50 return bestMatch;
51 }

◆ SelectProperty()

override PropertyInfo IKVM.Reflection.DefaultBinder.SelectProperty ( BindingFlags bindingAttr,
PropertyInfo[] match,
Type returnType,
Type[] indexes,
ParameterModifier[] modifiers )

Definition at line 282 of file DefaultBinder.cs.

283 {
284 var matchCount = 0;
285
286 foreach (var property in match)
287 {
288 if (indexes == null || MatchParameterTypes(property.GetIndexParameters(), indexes))
289 {
290 if (returnType != null)
291 {
292 if (property.PropertyType.IsPrimitive)
293 {
294 if (!IsAllowedPrimitiveConversion(returnType, property.PropertyType))
295 continue;
296 }
297 else
298 {
299 if (!property.PropertyType.IsAssignableFrom(returnType))
300 continue;
301 }
302 }
303
304 match[matchCount++] = property;
305 }
306 }
307
308 if (matchCount == 0)
309 return null;
310
311 if (matchCount == 1)
312 return match[0];
313
314 var bestMatch = match[0];
315 var ambiguous = false;
316 for (int i = 1; i < matchCount; i++)
317 {
318 var best = MatchTypes(bestMatch.PropertyType, match[i].PropertyType, returnType);
319
320 if (best == 0 && indexes != null)
321 best = MatchSignatures(bestMatch.PropertySignature, match[i].PropertySignature, indexes);
322
323 if (best == 0)
324 {
325 var depth1 = GetInheritanceDepth(bestMatch.DeclaringType);
326 var depth2 = GetInheritanceDepth(match[i].DeclaringType);
327 if (bestMatch.Name == match[i].Name && depth1 != depth2)
328 {
329 if (depth1 > depth2)
330 best = 1;
331 else
332 best = 2;
333 }
334 else
335 {
336 ambiguous = true;
337 }
338 }
339
340 if (best == 2)
341 {
342 ambiguous = false;
343 bestMatch = match[i];
344 }
345 }
346
347 if (ambiguous)
348 throw new AmbiguousMatchException();
349
350 return bestMatch;
351 }

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