PageRenderTime 59ms CodeModel.GetById 55ms app.highlight 1ms RepoModel.GetById 2ms app.codeStats 0ms

/src/LinFu.IoC/Factories/BaseFactory.cs

http://github.com/philiplaureano/LinFu
C# | 36 lines | 12 code | 3 blank | 21 comment | 0 complexity | f35739f06a063523f3be5ab00f6e434a MD5 | raw file
 1using LinFu.IoC.Interfaces;
 2
 3namespace LinFu.IoC.Factories
 4{
 5    /// <summary>
 6    ///     A factory base class that combines both the IFactory and
 7    ///     the IFactory&lt;T&gt; interfaces into a single class.
 8    /// </summary>
 9    /// <typeparam name="T"></typeparam>
10    public abstract class BaseFactory<T> : IFactory<T>, IFactory
11    {
12        /// <summary>
13        ///     Creates a service instance using the given container.
14        /// </summary>
15        /// <param name="request">The <see cref="IFactoryRequest" /> instance that describes the requested service.</param>
16        /// <returns>An object instance that represents the service to be created. This cannot be <c>null</c>.</returns>
17        object IFactory.CreateInstance(IFactoryRequest request)
18        {
19            return CreateInstance(request);
20        }
21
22
23        /// <summary>
24        ///     Creates a service instance using the given container.
25        /// </summary>
26        /// <remarks>
27        ///     <see cref="IFactory" /> developers can inherit from this class
28        ///     instead of having to write their own custom factories
29        ///     from scratch. This should cut down on some of the boilerplate
30        ///     code necessary to get a factory class up and running.
31        /// </remarks>
32        /// <param name="request">The <see cref="IFactoryRequest" /> instance that describes the requested service.</param>
33        /// <returns>An object instance that represents the service to be created. This cannot be <c>null</c>.</returns>
34        public abstract T CreateInstance(IFactoryRequest request);
35    }
36}