Mono.Cecil.Cil.Instruction.Create C# (CSharp) Method

Create() public static method

public static Create ( Mono.Cecil.Cil.OpCode opcode ) : Instruction
opcode Mono.Cecil.Cil.OpCode
return Instruction
        public static Instruction Create(OpCode opcode)
        {
            if (opcode.OperandType != OperandType.InlineNone)
                throw new ArgumentException ("opcode");

            return new Instruction (opcode, null);
        }

Same methods

Instruction::Create ( Mono.Cecil.Cil.OpCode opcode, CallSite site ) : Instruction
Instruction::Create ( Mono.Cecil.Cil.OpCode opcode, FieldReference field ) : Instruction
Instruction::Create ( Mono.Cecil.Cil.OpCode opcode, Instruction target ) : Instruction
Instruction::Create ( Mono.Cecil.Cil.OpCode opcode, MethodReference method ) : Instruction
Instruction::Create ( Mono.Cecil.Cil.OpCode opcode, ParameterDefinition parameter ) : Instruction
Instruction::Create ( Mono.Cecil.Cil.OpCode opcode, TypeReference type ) : Instruction
Instruction::Create ( Mono.Cecil.Cil.OpCode opcode, Mono.Cecil.Cil.VariableDefinition variable ) : Instruction
Instruction::Create ( Mono.Cecil.Cil.OpCode opcode, byte value ) : Instruction
Instruction::Create ( Mono.Cecil.Cil.OpCode opcode, double value ) : Instruction
Instruction::Create ( Mono.Cecil.Cil.OpCode opcode, float value ) : Instruction
Instruction::Create ( Mono.Cecil.Cil.OpCode opcode, int value ) : Instruction
Instruction::Create ( Mono.Cecil.Cil.OpCode opcode, long value ) : Instruction
Instruction::Create ( Mono.Cecil.Cil.OpCode opcode, sbyte value ) : Instruction
Instruction::Create ( Mono.Cecil.Cil.OpCode opcode, string value ) : Instruction

Usage Example

Esempio n. 1
0
 private void InsertAndBoxConstant(Injector injector, object constant, TypeReference type, TypeReference boxType = null)
 {
     if (type.IsType <string>())
     {
         injector.Insert(OpCodes.Ldstr, (string)constant);
     }
     else if (type.IsType <int>())
     {
         injector.Insert(OpCodes.Ldc_I4, (int)constant);
     }
     else if (type.IsType <long>())
     {
         injector.Insert(OpCodes.Ldc_I8, (long)constant);
     }
     else if (type.IsType <double>())
     {
         injector.Insert(OpCodes.Ldc_R8, (double)constant);
     }
     else if (type.IsType <float>())
     {
         injector.Insert(OpCodes.Ldc_R4, (float)constant);
     }
     else if (type.IsType <short>())
     {
         injector.Insert(OpCodes.Ldc_I4, (short)constant);
     }
     else if (type.IsType <byte>())
     {
         injector.Insert(OpCodes.Ldc_I4, (byte)constant);
     }
     else if (type.IsType <uint>())
     {
         injector.Insert(OpCodes.Ldc_I4, (int)(uint)constant);
     }
     else if (type.IsType <ulong>())
     {
         injector.Insert(OpCodes.Ldc_I8, (long)(ulong)constant);
     }
     else if (type.IsType <ushort>())
     {
         injector.Insert(OpCodes.Ldc_I4, (ushort)constant);
     }
     else if (type.IsType <sbyte>())
     {
         injector.Insert(OpCodes.Ldc_I4, (sbyte)constant);
     }
     if (boxType != null)
     {
         injector.Insert(Instruction.Create(OpCodes.Box, boxType));
     }
     Logger.Warning($"Unknown constant type {constant.GetType().FullName}");
 }
All Usage Examples Of Mono.Cecil.Cil.Instruction::Create