PageRenderTime 102ms CodeModel.GetById 40ms app.highlight 1ms RepoModel.GetById 59ms app.codeStats 0ms

/src/LinFu.IoC/DefaultCreator.cs

http://github.com/philiplaureano/LinFu
C# | 30 lines | 14 code | 3 blank | 13 comment | 2 complexity | 8e2587b5e8fe3d124ff06502981deee8 MD5 | raw file
 1using LinFu.IoC.Interfaces;
 2
 3namespace LinFu.IoC
 4{
 5    /// <summary>
 6    ///     Represents the default implementation for the <see cref="ICreateInstance" />
 7    /// </summary>
 8    public class DefaultCreator : ICreateInstance
 9    {
10        /// <summary>
11        ///     Creates a service instance using the given <paramref name="factoryRequest" /> and <see cref="IFactory" /> instance.
12        /// </summary>
13        /// <param name="factoryRequest">
14        ///     The <see cref="IFactoryRequest" /> instance that describes the context of the service
15        ///     request.
16        /// </param>
17        /// <param name="factory">The <see cref="IFactory" /> instance that will be used to instantiate the service type.</param>
18        /// <returns>A valid service instance.</returns>
19        public virtual object CreateFrom(IFactoryRequest factoryRequest, IFactory factory)
20        {
21            object instance = null;
22
23            // Generate the service instance
24            if (factory != null)
25                instance = factory.CreateInstance(factoryRequest);
26
27            return instance;
28        }        
29    }
30}