/src/LinFu.AOP/Interfaces/INewObjectWeaver.cs

http://github.com/philiplaureano/LinFu · C# · 42 lines · 12 code · 3 blank · 27 comment · 0 complexity · 3021bcc1853dc9ea6c063050d24f906b MD5 · raw file

  1. using Mono.Cecil;
  2. using Mono.Cecil.Cil;
  3. namespace LinFu.AOP.Cecil.Interfaces
  4. {
  5. /// <summary>
  6. /// Represents a type that can emit IL that instantiates an object
  7. /// within a given method.
  8. /// </summary>
  9. public interface INewObjectWeaver : IHostWeaver<TypeDefinition>
  10. {
  11. /// <summary>
  12. /// Adds local variables to the <paramref name="hostMethod" />.
  13. /// </summary>
  14. /// <param name="hostMethod">The target method.</param>
  15. void AddLocals(MethodDefinition hostMethod);
  16. /// <summary>
  17. /// Determines whether or not the object instantiation call to the <paramref name="constructor" />
  18. /// should be instrumented.
  19. /// </summary>
  20. /// <param name="constructor">The constructor that will be used to instantiate the target type.</param>
  21. /// <param name="concreteType">The type to be created.</param>
  22. /// <param name="hostMethod">The method that contains the instantiation request.</param>
  23. /// <returns>
  24. /// <c>true</c> if the call to the <c>new</c> operator should be intercepted; otherwise, it should return
  25. /// <c>false</c>.
  26. /// </returns>
  27. bool ShouldIntercept(MethodReference constructor, TypeReference concreteType, MethodReference hostMethod);
  28. /// <summary>
  29. /// Emits the necessary <paramref name="IL" /> necessary to instantiate
  30. /// the <paramref name="concreteType" />.
  31. /// </summary>
  32. /// <param name="hostMethod">The method that contains the activation request.</param>
  33. /// <param name="IL">The ILProcessor that will be used to replace the existing instructions in the method body.</param>
  34. /// <param name="targetConstructor">The constructor that is currently being used to instantiate the concrete type.</param>
  35. /// <param name="concreteType">The <see cref="System.Type" /> that describes the object type that needs to be instantiated.</param>
  36. void EmitNewObject(MethodDefinition hostMethod, ILProcessor IL, MethodReference targetConstructor,
  37. TypeReference concreteType);
  38. }
  39. }