private static object ReadRawOperand(IBinaryStreamReader reader, MsilOperandType msilOperandType) { switch (msilOperandType) { case MsilOperandType.InlineNone: return(null); case MsilOperandType.InlineArgument: case MsilOperandType.InlineVar: return(reader.ReadUInt16()); case MsilOperandType.InlineI: case MsilOperandType.InlineBrTarget: return(reader.ReadInt32()); case MsilOperandType.ShortInlineArgument: case MsilOperandType.ShortInlineVar: return(reader.ReadByte()); case MsilOperandType.ShortInlineBrTarget: case MsilOperandType.ShortInlineI: return(reader.ReadSByte()); case MsilOperandType.ShortInlineR: return(reader.ReadSingle()); case MsilOperandType.InlineR: return(reader.ReadDouble()); case MsilOperandType.InlineI8: return(reader.ReadInt64()); case MsilOperandType.InlineField: case MsilOperandType.InlineMethod: case MsilOperandType.InlineSig: case MsilOperandType.InlineTok: case MsilOperandType.InlineType: case MsilOperandType.InlineString: return(new MetadataToken(reader.ReadUInt32())); case MsilOperandType.InlineSwitch: var offsets = new int[reader.ReadUInt32()]; for (int i = 0; i < offsets.Length; i++) { offsets[i] = reader.ReadInt32(); } return(offsets); } throw new NotSupportedException(); }
private static object ReadRawOperand(IBinaryStreamReader reader, MsilOperandType msilOperandType) { switch (msilOperandType) { case MsilOperandType.InlineNone: return null; case MsilOperandType.InlineArgument: case MsilOperandType.InlineVar: return reader.ReadUInt16(); case MsilOperandType.InlineI: case MsilOperandType.InlineBrTarget: return reader.ReadInt32(); case MsilOperandType.ShortInlineArgument: case MsilOperandType.ShortInlineVar: return reader.ReadByte(); case MsilOperandType.ShortInlineBrTarget: case MsilOperandType.ShortInlineI: return reader.ReadSByte(); case MsilOperandType.ShortInlineR: return reader.ReadSingle(); case MsilOperandType.InlineR: return reader.ReadDouble(); case MsilOperandType.InlineI8: return reader.ReadInt64(); case MsilOperandType.InlineField : case MsilOperandType.InlineMethod : case MsilOperandType.InlineSig: case MsilOperandType.InlineTok: case MsilOperandType.InlineType: case MsilOperandType.InlineString: return new MetadataToken(reader.ReadUInt32()); case MsilOperandType.InlineSwitch: var offsets = new int[reader.ReadUInt32()]; for (int i = 0; i < offsets.Length; i++) offsets[i] = reader.ReadInt32(); return offsets; } throw new NotSupportedException(); }