private Module LoadModule(int index, byte[] rawModule, string location)
 {
     if ((manifestModule.File.records[index].Flags & ContainsNoMetaData) != 0)
     {
         return(externalModules[index] = new ResourceModule(this, manifestModule.GetString(manifestModule.File.records[index].Name), location));
     }
     else
     {
         return(externalModules[index] = new ModuleReader(this, manifestModule.universe, new MemoryStream(rawModule), location));
     }
 }
Beispiel #2
0
        private Module LoadModule(int index, byte[] rawModule, string name)
        {
            string location = name == null ? null : Path.Combine(Path.GetDirectoryName(this.location), name);

            if ((manifestModule.File.records[index].Flags & ContainsNoMetaData) != 0)
            {
                return(externalModules[index] = new ResourceModule(manifestModule, index, location));
            }
            else
            {
                if (rawModule == null)
                {
                    try
                    {
                        rawModule = File.ReadAllBytes(location);
                    }
                    catch (FileNotFoundException)
                    {
                        if (resolvers != null)
                        {
                            ResolveEventArgs arg = new ResolveEventArgs(name, this);
                            foreach (ModuleResolveEventHandler resolver in resolvers)
                            {
                                Module module = resolver(this, arg);
                                if (module != null)
                                {
                                    return(module);
                                }
                            }
                        }
                        if (universe.MissingMemberResolution)
                        {
                            return(externalModules[index] = new MissingModule(this, index));
                        }
                        throw;
                    }
                }
                return(externalModules[index] = new ModuleReader(this, manifestModule.universe, new MemoryStream(rawModule), location, false));
            }
        }
Beispiel #3
0
 private Module LoadModule(int index, byte[] rawModule, string location)
 {
     if ((manifestModule.File.records[index].Flags & ContainsNoMetaData) != 0)
     {
         return externalModules[index] = new ResourceModule(manifestModule, index, location);
     }
     else
     {
         if (rawModule == null)
         {
             rawModule = File.ReadAllBytes(location);
         }
         return externalModules[index] = new ModuleReader(this, manifestModule.universe, new MemoryStream(rawModule), location);
     }
 }
Beispiel #4
0
 private Module LoadModule(int index, byte[] rawModule, string name)
 {
     string location = name == null ? null : Path.Combine(Path.GetDirectoryName(this.location), name);
     if ((manifestModule.File.records[index].Flags & ContainsNoMetaData) != 0)
     {
         return externalModules[index] = new ResourceModule(manifestModule, index, location);
     }
     else
     {
         if (rawModule == null)
         {
             try
             {
                 rawModule = File.ReadAllBytes(location);
             }
             catch (FileNotFoundException)
             {
                 if (resolvers != null)
                 {
                     ResolveEventArgs arg = new ResolveEventArgs(name, this);
                     foreach (ModuleResolveEventHandler resolver in resolvers)
                     {
                         Module module = resolver(this, arg);
                         if (module != null)
                         {
                             return module;
                         }
                     }
                 }
                 if (universe.MissingMemberResolution)
                 {
                     return externalModules[index] = new MissingModule(this, index);
                 }
                 throw;
             }
         }
         return externalModules[index] = new ModuleReader(this, manifestModule.universe, new MemoryStream(rawModule), location);
     }
 }