AsmResolver.Net.Msil.MsilInstruction.OperandToString C# (CSharp) Method

OperandToString() public method

public OperandToString ( ) : string
return string
        public string OperandToString()
        {
            if (Operand == null)
                return string.Empty;

            switch (OpCode.OperandType)
            {
                case MsilOperandType.InlineNone:
                    return string.Empty;

                case MsilOperandType.InlineArgument:
                case MsilOperandType.ShortInlineArgument:
                case MsilOperandType.InlineVar:
                case MsilOperandType.ShortInlineVar:
                    // TODO: return index

                case MsilOperandType.InlineR:
                case MsilOperandType.ShortInlineR:
                case MsilOperandType.InlineI:
                case MsilOperandType.InlineI8:
                case MsilOperandType.ShortInlineI:
                    return Convert.ToString(Operand, CultureInfo.InvariantCulture);

                case MsilOperandType.InlineField:
                case MsilOperandType.InlineMethod:
                case MsilOperandType.InlineSig:
                case MsilOperandType.InlineTok:
                case MsilOperandType.InlineType:
                    var member = Operand as IMetadataMember;
                    return member != null
                        ? member.ToString()
                        : "TOKEN<0x" + ((MetadataToken) Operand) + ">";

                case MsilOperandType.InlineString:
                    return Operand is string
                        ? string.Format("\"{0}\"", Operand)
                        : "TOKEN<0x" + ((MetadataToken) Operand) + ">";
                case MsilOperandType.InlineSwitch:
                    return string.Join(", ", ((MsilInstruction[])Operand).Select(x => "IL_" + x.Offset.ToString("X4")));

                case MsilOperandType.InlineBrTarget:
                case MsilOperandType.ShortInlineBrTarget:
                    return "IL_" + ((MsilInstruction)Operand).Offset.ToString("X4");
            }
            throw new NotSupportedException();
        }