public static CSharpCDI ParseCDI(byte[] val) { CDIReader r = new CDIReader(val); CSharpCDI cdi = new CSharpCDI(); try { // Read the CDIGlobal header byte version = r.ReadByte(); if (version != CDIVERSION) throw new FormatException("Got unexpected CDIGlobal version: " + version); cdi.version = version; byte count = r.ReadByte(); r.SkipPadding(4); cdi.entries = new CDIItem[count]; // Read each CDI record for (int i = 0; i < count; i++) { cdi.entries[i] = r.ReadItem(); } } catch (EndOfStreamException e) { throw new FormatException("Unexpected end of CDI stream", e); } return cdi; }
private CDIWriter(CSharpCDI cdi) : base(new MemoryStream(), Encoding.Unicode) { }
public static byte[] WriteCDI(CSharpCDI cdi) { CDIWriter writer = new CDIWriter(cdi); writer.Write((byte)cdi.version); writer.Write((byte)cdi.entries.Length); writer.WritePadding(4); foreach (CDIItem i in cdi.entries) writer.WriteItem(i); return writer.GetBytes(); }
private void WriteCSharpCDI(CSharpCDI cdi, SymbolToken methodToken) { byte[] val = CDIWriter.WriteCDI(cdi); m_writer.SetSymAttribute(methodToken, "MD2", val); }