Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- internal static void Resolve(ref byte[] buffer, int[] index, Type[] resTypes, string[] resVars, Type[][] funParamTypes, DynamicILInfo dil)
- {
- int value = 0;
- for (int i = 0; i < index.Length; i++)
- {
- MemberInfo[] member = resTypes[i].GetMember(resVars[i], BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
- bool flag = false;
- if (member.Length == 0)
- {
- value = dil.GetTokenFor(resTypes[i].TypeHandle);
- flag = true;
- }
- else
- {
- int j = 0;
- while (j < member.Length)
- {
- MemberTypes memberType = member[j].MemberType;
- if (memberType == MemberTypes.Constructor)
- {
- goto IL_7C;
- }
- if (memberType == MemberTypes.Field)
- {
- FieldInfo fieldInfo = member[j] as FieldInfo;
- value = dil.GetTokenFor(fieldInfo.FieldHandle);
- flag = true;
- goto IL_F0;
- }
- if (memberType != MemberTypes.Method)
- {
- goto IL_F0;
- }
- goto IL_7C;
- IL_F3:
- j++;
- continue;
- IL_7C:
- Type[] array = funParamTypes[i];
- MethodBase methodBase = member[j] as MethodBase;
- ParameterInfo[] parameters = methodBase.GetParameters();
- if (array.Length != parameters.Length)
- {
- goto IL_F3;
- }
- bool flag2 = true;
- for (int k = 0; k < parameters.Length; k++)
- {
- if (parameters[k].ParameterType != array[parameters[k].Position])
- {
- flag2 = false;
- break;
- }
- }
- if (!flag2)
- {
- goto IL_F3;
- }
- value = dil.GetTokenFor((member[j] as MethodBase).MethodHandle);
- flag = true;
- IL_F0:
- if (!flag)
- {
- goto IL_F3;
- }
- break;
- }
- }
- if (!flag)
- {
- throw new ApplicationException(string.Format("Can not resolve token for type {0}, value {0}", resTypes[i].ToString(), resVars[i]));
- }
- byte[] bytes = BitConverter.GetBytes(value);
- Buffer.BlockCopy(bytes, 0, buffer, index[i], bytes.Length);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement