internal void Finish() { if (bb != null) { throw new InvalidOperationException(); } bb = new ByteBuffer(1024); linkOffsets = new List <int>(); root.Write(bb, linkOffsets); root = null; }
private static void ExtractResources(ResourceDirectoryEntry root, byte[] buf) { ByteReader br = new ByteReader(buf, 0, buf.Length); while (br.Length >= 32) { br.Align(4); RESOURCEHEADER hdr = new RESOURCEHEADER(br); if (hdr.DataSize != 0) { root[hdr.TYPE][hdr.NAME][new OrdinalOrName(hdr.LanguageId)].Data = ByteBuffer.Wrap(br.ReadBytes(hdr.DataSize)); } } }
internal ResourceSection(ByteBuffer versionInfo, byte[] unmanagedResources) { ResourceDirectoryEntry root = new ResourceDirectoryEntry(new OrdinalOrName("root")); if (versionInfo != null) { root[new OrdinalOrName(16)][new OrdinalOrName(1)][new OrdinalOrName(0)].Data = versionInfo; } else if (unmanagedResources != null) { ExtractResources(root, unmanagedResources); } root.Write(bb, linkOffsets); }
internal ResourceDirectoryEntry this[OrdinalOrName id] { get { foreach (ResourceDirectoryEntry entry in entries) { if (entry.OrdinalOrName.IsEqual(id)) { return(entry); } } // the entries must be sorted ResourceDirectoryEntry newEntry = new ResourceDirectoryEntry(id); if (id.Name == null) { for (int i = namedEntries; i < entries.Count; i++) { if (entries[i].OrdinalOrName.IsGreaterThan(id)) { entries.Insert(i, newEntry); return(newEntry); } } entries.Add(newEntry); return(newEntry); } else { for (int i = 0; i < namedEntries; i++) { if (entries[i].OrdinalOrName.IsGreaterThan(id)) { entries.Insert(i, newEntry); namedEntries++; return(newEntry); } } entries.Insert(namedEntries++, newEntry); return(newEntry); } } }
internal ResourceDirectoryEntry this[OrdinalOrName id] { get { foreach (ResourceDirectoryEntry entry in entries) { if (entry.OrdinalOrName.Ordinal == id.Ordinal && entry.OrdinalOrName.Name == id.Name) { return(entry); } } ResourceDirectoryEntry newEntry = new ResourceDirectoryEntry(id); if (id.Name == null) { entries.Add(newEntry); } else { entries.Insert(namedEntries++, newEntry); } return(newEntry); } }
internal ResourceDirectoryEntry this[OrdinalOrName id] { get { foreach (ResourceDirectoryEntry entry in entries) { if (entry.OrdinalOrName.Ordinal == id.Ordinal && entry.OrdinalOrName.Name == id.Name) { return entry; } } ResourceDirectoryEntry newEntry = new ResourceDirectoryEntry(id); if (id.Name == null) { entries.Add(newEntry); } else { entries.Insert(namedEntries++, newEntry); } return newEntry; } }
internal void Finish() { if (bb != null) { throw new InvalidOperationException(); } bb = new ByteBuffer(1024); linkOffsets = new List<int>(); root.Write(bb, linkOffsets); root = null; }
internal ResourceDirectoryEntry this[OrdinalOrName id] { get { foreach (ResourceDirectoryEntry entry in entries) { if (entry.OrdinalOrName.IsEqual(id)) { return entry; } } // the entries must be sorted ResourceDirectoryEntry newEntry = new ResourceDirectoryEntry(id); if (id.Name == null) { for (int i = namedEntries; i < entries.Count; i++) { if (entries[i].OrdinalOrName.IsGreaterThan(id)) { entries.Insert(i, newEntry); return newEntry; } } entries.Add(newEntry); return newEntry; } else { for (int i = 0; i < namedEntries; i++) { if (entries[i].OrdinalOrName.IsGreaterThan(id)) { entries.Insert(i, newEntry); namedEntries++; return newEntry; } } entries.Insert(namedEntries++, newEntry); return newEntry; } } }