/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
- using LinFu.IoC.Interfaces;
- namespace LinFu.IoC
- {
- /// <summary>
- /// Represents the default implementation for the <see cref="ICreateInstance" />
- /// </summary>
- public class DefaultCreator : ICreateInstance
- {
- /// <summary>
- /// Creates a service instance using the given <paramref name="factoryRequest" /> and <see cref="IFactory" /> instance.
- /// </summary>
- /// <param name="factoryRequest">
- /// The <see cref="IFactoryRequest" /> instance that describes the context of the service
- /// request.
- /// </param>
- /// <param name="factory">The <see cref="IFactory" /> instance that will be used to instantiate the service type.</param>
- /// <returns>A valid service instance.</returns>
- public virtual object CreateFrom(IFactoryRequest factoryRequest, IFactory factory)
- {
- object instance = null;
- // Generate the service instance
- if (factory != null)
- instance = factory.CreateInstance(factoryRequest);
- return instance;
- }
- }
- }