void InitTokenToType() { moduleType = moduleDef.Types[0]; foreach (var typeDef in moduleDef.GetTypes()) { int token = (int)typeDef.MDToken.Raw; Type type; try { type = module.ResolveType(token); } catch { tokenToType[token] = null; typeRefToType.Add(typeDef, null); continue; } var mtype = new MType(type, typeDef); tokenToType[token] = mtype; typeRefToType.Add(typeDef, mtype); } }
void initTokenToType() { moduleType = DotNetUtils.getModuleType(moduleDefinition); foreach (var typeDefinition in moduleDefinition.GetTypes()) { int token = typeDefinition.MetadataToken.ToInt32(); Type type; try { type = module.ResolveType(token); } catch { tokenToType[token] = null; typeReferenceToType.add(typeDefinition, null); continue; } var mtype = new MType(type, typeDefinition); tokenToType[token] = mtype; typeReferenceToType.add(typeDefinition, mtype); } }
void initTokenToType() { var tmpTokenToType = new Dictionary<int, Type>(); var tmpTokenToTypeDefinition = new Dictionary<int, TypeDefinition>(); foreach (var t in module.GetTypes()) tmpTokenToType[t.MetadataToken] = t; foreach (var t in moduleDefinition.GetTypes()) { tmpTokenToTypeDefinition[t.MetadataToken.ToInt32()] = t; if (moduleType == null && t.FullName == "<Module>") moduleType = t; } foreach (var token in tmpTokenToType.Keys) { var mtype = new MType(tmpTokenToType[token], tmpTokenToTypeDefinition[token]); tokenToType[token] = mtype; typeReferenceToType[new TypeReferenceKey(mtype.typeDefinition)] = mtype; } }