PageRenderTime 41ms CodeModel.GetById 39ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/src/LinFu.IoC/Factories/InstanceFactory.cs

http://github.com/philiplaureano/LinFu
C# | 34 lines | 16 code | 4 blank | 14 comment | 0 complexity | 0a9cbf660ce12aff6fe9139c36ec4022 MD5 | raw file
 1using LinFu.IoC.Interfaces;
 2
 3namespace LinFu.IoC
 4{
 5    /// <summary>
 6    ///     A factory that uses an existing object reference
 7    ///     instead of creating a new service.
 8    /// </summary>
 9    public class InstanceFactory : IFactory
10    {
11        private readonly object _instance;
12
13        /// <summary>
14        ///     Creates a factory using the existing <paramref name="instance" />.
15        /// </summary>
16        /// <param name="instance">The existing object reference that the factory will return.</param>
17        public InstanceFactory(object instance)
18        {
19            _instance = instance;
20        }
21
22
23        /// <summary>
24        ///     A method that returns the existing object reference associated with
25        ///     this factory.
26        /// </summary>
27        /// <param name="request">The <see cref="IFactoryRequest" /> instance that describes the requested service.</param>
28        /// <returns>A non-null object reference.</returns>
29        public object CreateInstance(IFactoryRequest request)
30        {
31            return _instance;
32        }
33    }
34}