/src/LinFu.AOP/InstructionProvider.cs

http://github.com/philiplaureano/LinFu · C# · 27 lines · 16 code · 2 blank · 9 comment · 0 complexity · 7228917681ec013df7b2357e3f577cd5 MD5 · raw file

  1. using System.Collections.Generic;
  2. using LinFu.AOP.Cecil.Interfaces;
  3. using Mono.Cecil;
  4. using Mono.Cecil.Cil;
  5. namespace LinFu.AOP.Cecil
  6. {
  7. /// <summary>
  8. /// Represents the default implementation of the <see cref="IInstructionProvider" /> class.
  9. /// </summary>
  10. internal class InstructionProvider : IInstructionProvider
  11. {
  12. /// <summary>
  13. /// Determines the instructions for a given method.
  14. /// </summary>
  15. /// <param name="method">The source method that contains the instructions.</param>
  16. /// <returns>The set of instructions for the given method.</returns>
  17. public IEnumerable<Instruction> GetInstructions(MethodDefinition method)
  18. {
  19. // Save the old instructions
  20. var oldInstructions = new LinkedList<Instruction>();
  21. foreach (Instruction instruction in method.Body.Instructions) oldInstructions.AddLast(instruction);
  22. return oldInstructions;
  23. }
  24. }
  25. }