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

◆ GetMethodBase() [4/4]

static MethodBase System.RuntimeType.GetMethodBase ( RuntimeType reflectedType,
RuntimeMethodHandleInternal methodHandle )
inlinestaticpackage

Definition at line 1692 of file RuntimeType.cs.

1693 {
1694 if (RuntimeMethodHandle.IsDynamicMethod(methodHandle))
1695 {
1696 return RuntimeMethodHandle.GetResolver(methodHandle)?.GetDynamicMethod();
1697 }
1698 RuntimeType runtimeType = RuntimeMethodHandle.GetDeclaringType(methodHandle);
1699 RuntimeType[] array = null;
1700 if ((object)reflectedType == null)
1701 {
1703 }
1704 if (reflectedType != runtimeType && !reflectedType.IsSubclassOf(runtimeType))
1705 {
1706 if (reflectedType.IsArray)
1707 {
1708 MethodBase[] array2 = reflectedType.GetMember(RuntimeMethodHandle.GetName(methodHandle), MemberTypes.Constructor | MemberTypes.Method, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) as MethodBase[];
1709 bool flag = false;
1710 for (int i = 0; i < array2.Length; i++)
1711 {
1712 IRuntimeMethodInfo runtimeMethodInfo = (IRuntimeMethodInfo)array2[i];
1713 if (runtimeMethodInfo.Value.Value == methodHandle.Value)
1714 {
1715 flag = true;
1716 }
1717 }
1718 if (!flag)
1719 {
1720 throw new ArgumentException(SR.Format(SR.Argument_ResolveMethodHandle, reflectedType, runtimeType));
1721 }
1722 }
1723 else if (runtimeType.IsGenericType)
1724 {
1725 RuntimeType runtimeType2 = (RuntimeType)runtimeType.GetGenericTypeDefinition();
1727 while (runtimeType3 != null)
1728 {
1730 if (runtimeType4.IsGenericType && !runtimeType3.IsGenericTypeDefinition)
1731 {
1732 runtimeType4 = (RuntimeType)runtimeType4.GetGenericTypeDefinition();
1733 }
1735 {
1736 break;
1737 }
1738 runtimeType3 = runtimeType3.GetBaseType();
1739 }
1740 if (runtimeType3 == null)
1741 {
1742 throw new ArgumentException(SR.Format(SR.Argument_ResolveMethodHandle, reflectedType, runtimeType));
1743 }
1745 if (!RuntimeMethodHandle.IsGenericMethodDefinition(methodHandle))
1746 {
1747 array = RuntimeMethodHandle.GetMethodInstantiationInternal(methodHandle);
1748 }
1749 methodHandle = RuntimeMethodHandle.GetMethodFromCanonical(methodHandle, runtimeType);
1750 }
1751 else if (!runtimeType.IsAssignableFrom(reflectedType))
1752 {
1753 throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.Argument_ResolveMethodHandle, reflectedType.ToString(), runtimeType.ToString()));
1754 }
1755 }
1756 methodHandle = RuntimeMethodHandle.GetStubIfNeeded(methodHandle, runtimeType, array);
1757 MethodBase result = (RuntimeMethodHandle.IsConstructor(methodHandle) ? reflectedType.Cache.GetConstructor(runtimeType, methodHandle) : ((!RuntimeMethodHandle.HasMethodInstantiation(methodHandle) || RuntimeMethodHandle.IsGenericMethodDefinition(methodHandle)) ? reflectedType.Cache.GetMethod(runtimeType, methodHandle) : reflectedType.Cache.GetGenericMethodInfo(methodHandle)));
1758 GC.KeepAlive(array);
1759 return result;
1760 }
static CultureInfo CurrentCulture

References System.RuntimeType.RuntimeType(), System.SR.Argument_ResolveMethodHandle, System.array, System.Globalization.CultureInfo.CurrentCulture, System.SR.Format(), System.Format, System.RuntimeMethodHandle.GetDeclaringType(), System.RuntimeMethodHandle.GetMethodFromCanonical(), System.RuntimeMethodHandle.GetMethodInstantiationInternal(), System.RuntimeMethodHandle.GetName(), System.RuntimeMethodHandle.GetResolver(), System.RuntimeMethodHandle.GetStubIfNeeded(), System.RuntimeMethodHandle.HasMethodInstantiation(), System.RuntimeMethodHandle.IsConstructor(), System.RuntimeMethodHandle.IsDynamicMethod(), System.RuntimeMethodHandle.IsGenericMethodDefinition(), and System.GC.KeepAlive().