public byte[] convert() { var resources = new ResourceElementSet(); foreach (var info in infos) { resources.add(convert(info)); } var memStream = new MemoryStream(); ResourceWriter.write(module, memStream, resources); return(memStream.ToArray()); }
void rename(TypeDefinition type, EmbeddedResource resource) { newNames.Clear(); var resourceSet = ResourceReader.read(module, resource.GetResourceStream()); var renamed = new List <RenameInfo>(); foreach (var elem in resourceSet.ResourceElements) { if (nameChecker.isValidResourceKeyName(elem.Name)) { newNames.Add(elem.Name, true); continue; } renamed.Add(new RenameInfo(elem, getNewName(elem))); } if (renamed.Count == 0) { return; } rename(type, renamed); var outStream = new MemoryStream(); ResourceWriter.write(module, outStream, resourceSet); outStream.Position = 0; var newResource = new EmbeddedResource(resource.Name, resource.Attributes, outStream); int resourceIndex = module.Resources.IndexOf(resource); if (resourceIndex < 0) { throw new ApplicationException("Could not find index of resource"); } module.Resources[resourceIndex] = newResource; }