ServiceContainerFactory.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. using System;
  2. namespace Wayne.Lib
  3. {
  4. /// <summary>
  5. /// Factory to create ServiceContainer.
  6. /// </summary>
  7. public static class ServiceContainerFactory
  8. {
  9. /// <summary>
  10. /// Creates new service container.
  11. /// </summary>
  12. /// <returns>New service container.</returns>
  13. public static IServiceContainer Create()
  14. {
  15. return new ServiceContainer();
  16. }
  17. /// <summary>
  18. /// Creates new service container with a parent service locator from where the newly created service container
  19. /// can look for services if it does not find them in its own container.
  20. /// </summary>
  21. /// <param name="parentServiceLocator">Parent service container.</param>
  22. /// <returns>New service container.</returns>
  23. public static IServiceContainer Create(IServiceLocator parentServiceLocator)
  24. {
  25. return new ServiceContainer(parentServiceLocator);
  26. }
  27. public static IServiceContainer Create(Func<Type, object> resolver)
  28. {
  29. var container=new ServiceContainer();
  30. container.RegisterResolver(resolver);
  31. return container;
  32. }
  33. }
  34. }