/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
- using Mono.Cecil;
- using Mono.Cecil.Cil;
- namespace LinFu.AOP.Cecil.Interfaces
- {
- /// <summary>
- /// Represents a type that can emit IL that instantiates an object
- /// within a given method.
- /// </summary>
- public interface INewObjectWeaver : IHostWeaver<TypeDefinition>
- {
- /// <summary>
- /// Adds local variables to the <paramref name="hostMethod" />.
- /// </summary>
- /// <param name="hostMethod">The target method.</param>
- void AddLocals(MethodDefinition hostMethod);
- /// <summary>
- /// Determines whether or not the object instantiation call to the <paramref name="constructor" />
- /// should be instrumented.
- /// </summary>
- /// <param name="constructor">The constructor that will be used to instantiate the target type.</param>
- /// <param name="concreteType">The type to be created.</param>
- /// <param name="hostMethod">The method that contains the instantiation request.</param>
- /// <returns>
- /// <c>true</c> if the call to the <c>new</c> operator should be intercepted; otherwise, it should return
- /// <c>false</c>.
- /// </returns>
- bool ShouldIntercept(MethodReference constructor, TypeReference concreteType, MethodReference hostMethod);
- /// <summary>
- /// Emits the necessary <paramref name="IL" /> necessary to instantiate
- /// the <paramref name="concreteType" />.
- /// </summary>
- /// <param name="hostMethod">The method that contains the activation request.</param>
- /// <param name="IL">The ILProcessor that will be used to replace the existing instructions in the method body.</param>
- /// <param name="targetConstructor">The constructor that is currently being used to instantiate the concrete type.</param>
- /// <param name="concreteType">The <see cref="System.Type" /> that describes the object type that needs to be instantiated.</param>
- void EmitNewObject(MethodDefinition hostMethod, ILProcessor IL, MethodReference targetConstructor,
- TypeReference concreteType);
- }
- }