Exemple #1
0
        void InitGlobalMethods()
        {
            if (tokenToGlobalMethod != null)
            {
                return;
            }
            tokenToGlobalMethod = new Dictionary <int, MMethod>();

            var tmpTokenToGlobalMethod = new Dictionary <int, MethodInfo>();
            var flags = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;

            foreach (var m in module.GetMethods(flags))
            {
                tmpTokenToGlobalMethod[m.MetadataToken] = m;
            }
            foreach (var m in moduleType.Methods)
            {
                if (m.Name == ".cctor")                 //TODO: Use module.GetMethod(token) to get .cctor method
                {
                    continue;
                }
                var token = (int)m.MDToken.Raw;
                tokenToGlobalMethod[token] = new MMethod(tmpTokenToGlobalMethod[token], m);
            }
        }
Exemple #2
0
 public void SetMethodInfo(MMethod methodInfo)
 {
     this.methodInfo  = methodInfo;
     methodReturnType = ResolverUtils.GetReturnType(methodInfo.methodBase);
     methodParameters = GetMethodParameterTypes(methodInfo.methodBase);
     delegateType     = Utils.GetDelegateType(methodReturnType, methodParameters);
 }
Exemple #3
0
		void InitMethods() {
			if (tokenToMethod != null)
				return;
			tokenToMethod = new Dictionary<int, MMethod>(typeDef.Methods.Count);
			methodRefToMethod = new MethodDefDict<MMethod>();

			var tmpTokenToMethod = new Dictionary<int, MethodBase>();
			var flags = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
			foreach (var m in ResolverUtils.GetMethodBases(type, flags))
				tmpTokenToMethod[m.MetadataToken] = m;
			foreach (var m in typeDef.Methods) {
				var token = (int)m.MDToken.Raw;
				var method = new MMethod(tmpTokenToMethod[token], m);
				tokenToMethod[token] = method;
				methodRefToMethod.Add(method.methodDef, method);
			}
		}
        void InitMethods()
        {
            if (tokenToMethod != null)
            {
                return;
            }
            tokenToMethod     = new Dictionary <int, MMethod>(typeDef.Methods.Count);
            methodRefToMethod = new MethodDefDict <MMethod>();

            var tmpTokenToMethod = new Dictionary <int, MethodBase>();
            var flags            = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;

            foreach (var m in ResolverUtils.GetMethodBases(type, flags))
            {
                tmpTokenToMethod[m.MetadataToken] = m;
            }
            foreach (var m in typeDef.Methods)
            {
                var token  = (int)m.MDToken.Raw;
                var method = new MMethod(tmpTokenToMethod[token], m);
                tokenToMethod[token] = method;
                methodRefToMethod.Add(method.methodDef, method);
            }
        }
		void InitGlobalMethods() {
			if (tokenToGlobalMethod != null)
				return;
			tokenToGlobalMethod = new Dictionary<int, MMethod>();

			var tmpTokenToGlobalMethod = new Dictionary<int, MethodInfo>();
			var flags = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
			foreach (var m in module.GetMethods(flags))
				tmpTokenToGlobalMethod[m.MetadataToken] = m;
			foreach (var m in moduleType.Methods) {
				if (m.Name == ".cctor")	//TODO: Use module.GetMethod(token) to get .cctor method
					continue;
				var token = (int)m.MDToken.Raw;
				tokenToGlobalMethod[token] = new MMethod(tmpTokenToGlobalMethod[token], m);
			}
		}
Exemple #6
0
 public void setMethodInfo(MMethod methodInfo)
 {
     this.methodInfo = methodInfo;
     methodReturnType = ResolverUtils.getReturnType(methodInfo.methodBase);
     methodParameters = getMethodParameterTypes(methodInfo.methodBase);
     delegateType = Utils.getDelegateType(methodReturnType, methodParameters);
 }
Exemple #7
0
        void initMethods()
        {
            if (tokenToMethod != null)
                return;
            tokenToMethod = new Dictionary<int, MMethod>(typeDefinition.Methods.Count);
            methodReferenceToMethod = new Dictionary<MethodReferenceKey, MMethod>();

            var tmpTokenToMethod = new Dictionary<int, MethodBase>();
            var flags = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
            foreach (var m in ResolverUtils.getMethodBases(type, flags))
                tmpTokenToMethod[m.MetadataToken] = m;
            foreach (var m in typeDefinition.Methods) {
                var token = m.MetadataToken.ToInt32();
                var method = new MMethod(tmpTokenToMethod[token], m);
                tokenToMethod[token] = method;
                methodReferenceToMethod[new MethodReferenceKey(method.methodDefinition)] = method;
            }
        }