/src/LinFu.IoC.Common/IServiceContainer.cs

http://github.com/philiplaureano/LinFu · C# · 63 lines · 14 code · 5 blank · 44 comment · 0 complexity · bc6ec4505b93dbf4aff4e015d5eb8da2 MD5 · raw file

  1. using System;
  2. using System.Collections.Generic;
  3. namespace LinFu.IoC.Interfaces
  4. {
  5. /// <summary>
  6. /// An inversion of control container that supports
  7. /// named services.
  8. /// </summary>
  9. /// <seealso name="IContainer" />
  10. public interface IServiceContainer : IContainer
  11. {
  12. /// <summary>
  13. /// The list of preprocessors that will handle
  14. /// every service request before each actual service is created.
  15. /// </summary>
  16. IList<IPreProcessor> PreProcessors { get; }
  17. /// <summary>
  18. /// The list of postprocessors that will handle every
  19. /// service request result.
  20. /// </summary>
  21. IList<IPostProcessor> PostProcessors { get; }
  22. /// <summary>
  23. /// Adds an <see cref="IFactory" /> instance and associates it
  24. /// with the given <paramref name="serviceType">service type</paramref> and
  25. /// <paramref name="serviceName">service name</paramref>.
  26. /// </summary>
  27. /// <param name="serviceName">The name of the service to associate with the given <see cref="IFactory" /> instance.</param>
  28. /// <param name="serviceType">The type of service that the factory will be able to create.</param>
  29. /// <param name="additionalParameterTypes">The list of additional parameters that this factory type will support.</param>
  30. /// <param name="factory">The <see cref="IFactory" /> instance that will create the object instance.</param>
  31. void AddFactory(string serviceName, Type serviceType, IEnumerable<Type> additionalParameterTypes,
  32. IFactory factory);
  33. /// <summary>
  34. /// Determines whether or not a service can be created using
  35. /// the given <paramref name="serviceName">service name</paramref>
  36. /// and <paramref name="serviceType">service type</paramref>.
  37. /// </summary>
  38. /// <param name="serviceName">The name of the service to associate with the given <see cref="IFactory" /> instance.</param>
  39. /// <param name="serviceType">The type of service that the factory will be able to create.</param>
  40. /// <param name="additionalParameterTypes">The list of additional parameters that the factory type must support.</param>
  41. /// <returns>Returns <c>true</c> if the service exists; otherwise, it will return <c>false</c>.</returns>
  42. bool Contains(string serviceName, Type serviceType, IEnumerable<Type> additionalParameterTypes);
  43. /// <summary>
  44. /// Causes the container to instantiate the service with the given
  45. /// <paramref name="serviceType">service type</paramref>. If the service type cannot be created, then an
  46. /// exception will be thrown if the <see cref="IContainer.SuppressErrors" /> property
  47. /// is set to false. Otherwise, it will simply return null.
  48. /// </summary>
  49. /// <param name="serviceName">The name of the service to instantiate.</param>
  50. /// <param name="serviceType">The service type to instantiate.</param>
  51. /// <param name="additionalArguments">The additional arguments that will be used to instantiate the service type.</param>
  52. /// <returns>
  53. /// If successful, it will return a service instance that is compatible with the given type;
  54. /// otherwise, it will just return a <c>null</c> value.
  55. /// </returns>
  56. object GetService(string serviceName, Type serviceType, params object[] additionalArguments);
  57. }
  58. }