PageRenderTime 103ms CodeModel.GetById 81ms app.highlight 1ms RepoModel.GetById 19ms app.codeStats 0ms

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