Пример #1
0
        public IAssembly ResolveAssembly(ushort id)
        {
            id &= 0xfff;
            if (!assemblyMap.TryGetValue(id, out var assembly))
            {
                if (AssemblyIdMap.TryGetValue(id, out var assemblyRec))
                {
                    var assemblyName = new AssemblyNameInfo(assemblyRec.AssemblyFullName);

                    if (assemblyName.Name == Module.Assembly.Name)
                    {
                        assembly = Module.Assembly;
                    }
                    else
                    {
                        assembly = Module.Context.AssemblyResolver.Resolve(assemblyName, Module);
                    }

                    if (assembly == null)
                    {
                        assembly = assemblyName;
                    }
                }
                else
                {
                    assembly = null;
                }

                assemblyMap[id] = assembly;
            }
            return(assembly);
        }
Пример #2
0
        public IModule ResolveAssembly(ushort id)
        {
            id &= 0xfff;
            if (!assemblyMap.TryGetValue(id, out var assembly))
            {
                if (AssemblyIdMap.TryGetValue(id, out var assemblyRec))
                {
                    var assemblyName = Metadata.AssemblyNameReference.Parse(assemblyRec.AssemblyFullName);

                    if (assemblyName.Name == TypeSystem.MainModule.AssemblyName)
                    {
                        assembly = TypeSystem.MainModule;
                    }
                    else
                    {
                        assembly = TypeSystem.ReferencedModules.FirstOrDefault(m => m.FullAssemblyName == assemblyName.FullName);
                    }
                }
                else
                {
                    assembly = null;
                }

                assemblyMap[id] = assembly;
            }
            return(assembly);
        }