Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ SelectProperty() [1/2]

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

Definition at line 504 of file DefaultBinder.cs.

505 {
506 if (indexes != null)
507 {
508 foreach (Type type in indexes)
509 {
510 if (type == null)
511 {
512 throw new ArgumentNullException("indexes");
513 }
514 }
515 }
516 if (match == null || match.Length == 0)
517 {
518 throw new ArgumentException(SR.Arg_EmptyArray, "match");
519 }
520 PropertyInfo[] array = (PropertyInfo[])match.Clone();
521 int j = 0;
522 int num = 0;
523 int num2 = ((indexes != null) ? indexes.Length : 0);
524 for (int k = 0; k < array.Length; k++)
525 {
526 if (indexes != null)
527 {
528 ParameterInfo[] indexParameters = array[k].GetIndexParameters();
529 if (indexParameters.Length != num2)
530 {
531 continue;
532 }
533 for (j = 0; j < num2; j++)
534 {
535 Type parameterType = indexParameters[j].ParameterType;
536 if (parameterType == indexes[j] || parameterType == typeof(object))
537 {
538 continue;
539 }
540 if (parameterType.IsPrimitive)
541 {
542 if (!indexes[j].UnderlyingSystemType.IsRuntimeImplemented() || !CanChangePrimitive(indexes[j].UnderlyingSystemType, parameterType.UnderlyingSystemType))
543 {
544 break;
545 }
546 }
547 else if (!parameterType.IsAssignableFrom(indexes[j]))
548 {
549 break;
550 }
551 }
552 }
553 if (j != num2)
554 {
555 continue;
556 }
557 if (returnType != null)
558 {
559 if (array[k].PropertyType.IsPrimitive)
560 {
561 if (!returnType.UnderlyingSystemType.IsRuntimeImplemented() || !CanChangePrimitive(returnType.UnderlyingSystemType, array[k].PropertyType.UnderlyingSystemType))
562 {
563 continue;
564 }
565 }
566 else if (!array[k].PropertyType.IsAssignableFrom(returnType))
567 {
568 continue;
569 }
570 }
571 array[num++] = array[k];
572 }
573 switch (num)
574 {
575 case 0:
576 return null;
577 case 1:
578 return array[0];
579 default:
580 {
581 int num3 = 0;
582 bool flag = false;
583 int[] array2 = new int[num2];
584 for (int k = 0; k < num2; k++)
585 {
586 array2[k] = k;
587 }
588 for (int k = 1; k < num; k++)
589 {
590 int num4 = FindMostSpecificType(array[num3].PropertyType, array[k].PropertyType, returnType);
591 if (num4 == 0 && indexes != null)
592 {
593 num4 = FindMostSpecific(array[num3].GetIndexParameters(), array2, null, array[k].GetIndexParameters(), array2, null, indexes, null);
594 }
595 if (num4 == 0)
596 {
597 num4 = FindMostSpecificProperty(array[num3], array[k]);
598 if (num4 == 0)
599 {
600 flag = true;
601 }
602 }
603 if (num4 == 2)
604 {
605 flag = false;
606 num3 = k;
607 }
608 }
609 if (flag)
610 {
611 throw new AmbiguousMatchException(SR.Arg_AmbiguousMatchException);
612 }
613 return array[num3];
614 }
615 }
616 }
static bool CanChangePrimitive(Type source, Type target)
static int FindMostSpecificProperty(PropertyInfo cur1, PropertyInfo cur2)
static int FindMostSpecific(ParameterInfo[] p1, int[] paramOrder1, Type paramArrayType1, ParameterInfo[] p2, int[] paramOrder2, Type paramArrayType2, Type[] types, object[] args)
static int FindMostSpecificType(Type c1, Type c2, Type t)

References System.SR.Arg_AmbiguousMatchException, System.SR.Arg_EmptyArray, System.array, System.DefaultBinder.CanChangePrimitive(), System.DefaultBinder.FindMostSpecific(), System.DefaultBinder.FindMostSpecificProperty(), System.DefaultBinder.FindMostSpecificType(), System.Type.IsAssignableFrom(), System.Type.IsPrimitive, System.Type.IsRuntimeImplemented(), System.match, System.Reflection.ParameterInfo.ParameterType, System.type, and System.Type.UnderlyingSystemType.