internal static RuntimeMethodInfo AssignAssociates(int tkMethod, RuntimeTypeHandle declaredTypeHandle, RuntimeTypeHandle reflectedTypeHandle)
{
if (MetadataToken.IsNullToken(tkMethod))
{
return(null);
}
bool flag = !declaredTypeHandle.Equals(reflectedTypeHandle);
RuntimeMethodHandle methodHandle = declaredTypeHandle.GetModuleHandle().ResolveMethodHandle(tkMethod, declaredTypeHandle.GetInstantiation(), new RuntimeTypeHandle[0]);
MethodAttributes attributes = methodHandle.GetAttributes();
bool flag2 = (attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Private;
bool flag3 = (attributes & MethodAttributes.Virtual) != MethodAttributes.PrivateScope;
if (flag)
{
if (flag2)
{
return(null);
}
if (flag3 && ((declaredTypeHandle.GetAttributes() & TypeAttributes.ClassSemanticsMask) == TypeAttributes.AnsiClass))
{
int slot = methodHandle.GetSlot();
methodHandle = reflectedTypeHandle.GetMethodAt(slot);
}
}
MethodAttributes attributes2 = attributes & MethodAttributes.MemberAccessMask;
RuntimeMethodInfo methodBase = RuntimeType.GetMethodBase(reflectedTypeHandle, methodHandle) as RuntimeMethodInfo;
if (methodBase == null)
{
methodBase = reflectedTypeHandle.GetRuntimeType().Module.ResolveMethod(tkMethod, null, null) as RuntimeMethodInfo;
}
return(methodBase);
}