PageRenderTime 60ms CodeModel.GetById 56ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/src/LinFu.IoC/CreatorFromInstance.cs

http://github.com/philiplaureano/LinFu
C# | 36 lines | 16 code | 4 blank | 16 comment | 0 complexity | 211ad2b1fc43414a191eabb7bd93e399 MD5 | raw file
 1using LinFu.IoC.Interfaces;
 2
 3namespace LinFu.IoC
 4{
 5    /// <summary>
 6    ///     Represents an <see cref="ICreateInstance" /> type that generates an object instance from an existing instance.
 7    /// </summary>
 8    internal class CreatorFromInstance : ICreateInstance
 9    {
10        private readonly object _instance;
11
12        /// <summary>
13        ///     Initializes the class with the target <paramref name="instance" />.
14        /// </summary>
15        /// <param name="instance">The instance that will be returned every time the <see cref="CreateFrom" /> method is called.</param>
16        internal CreatorFromInstance(object instance)
17        {
18            _instance = instance;
19        }
20
21
22        /// <summary>
23        ///     Returns the object instance that given when the <see cref="CreatorFromInstance" /> class instance was initialized.
24        /// </summary>
25        /// <param name="factoryRequest">
26        ///     The <see cref="IFactoryRequest" /> instance that describes the context of the service
27        ///     request.
28        /// </param>
29        /// <param name="factory">The <see cref="IFactory" /> instance that will be used to instantiate the service type.</param>
30        /// <returns>A valid service instance.</returns>
31        public object CreateFrom(IFactoryRequest factoryRequest, IFactory factory)
32        {
33            return _instance;
34        }
35    }
36}