/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

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