ServiceContainerFactory.cs 1.2 KB

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