PageRenderTime 121ms CodeModel.GetById 45ms app.highlight 2ms RepoModel.GetById 53ms app.codeStats 0ms

/src/LinFu.IoC/Configuration/ConstructorInvoke.cs

http://github.com/philiplaureano/LinFu
C# | 26 lines | 14 code | 1 blank | 11 comment | 0 complexity | ee2aa88ea2f66ad0548efe37120f6541 MD5 | raw file
 1using System;
 2using System.Reflection;
 3using LinFu.IoC.Configuration.Interfaces;
 4
 5namespace LinFu.IoC.Configuration
 6{
 7    /// <summary>
 8    ///     A class that invokes constructor instances.
 9    /// </summary>
10    public class ConstructorInvoke : IMethodInvoke<ConstructorInfo>
11    {
12        /// <summary>
13        ///     Invokes the <paramref name="targetMethod" /> constructor
14        ///     using the given <paramref name="arguments" />.
15        /// </summary>
16        /// <param name="target">The target object instance.</param>
17        /// <param name="targetMethod">The target method to invoke.</param>
18        /// <param name="arguments">The arguments to be used with the method.</param>
19        /// <returns>The method return value.</returns>
20        public object Invoke(object target, ConstructorInfo targetMethod, params object[] arguments)
21        {
22            var declaringType = targetMethod.DeclaringType;
23            return Activator.CreateInstance(declaringType, arguments);
24        }
25    }
26}