public int GetOperandSize()
{
switch (OpCode.OperandType)
{
case MsilOperandType.InlineNone:
return 0;
case MsilOperandType.ShortInlineArgument:
case MsilOperandType.ShortInlineVar:
case MsilOperandType.ShortInlineI:
case MsilOperandType.ShortInlineBrTarget:
return 1;
case MsilOperandType.InlineVar:
case MsilOperandType.InlineArgument:
return 2;
case MsilOperandType.ShortInlineR:
case MsilOperandType.InlineI:
case MsilOperandType.InlineField:
case MsilOperandType.InlineMethod:
case MsilOperandType.InlineSig:
case MsilOperandType.InlineTok:
case MsilOperandType.InlineType:
case MsilOperandType.InlineString:
case MsilOperandType.InlineBrTarget:
return 4;
case MsilOperandType.InlineR:
case MsilOperandType.InlineI8:
return 8;
case MsilOperandType.InlineSwitch:
var array = Operand as Array;
if (array == null)
return 4;
return 4 * (array.GetLength(0) + 1);
}
throw new NotSupportedException();
}