/src/LinFu.IoC.Common/IContainer.cs

http://github.com/philiplaureano/LinFu · C# · 57 lines · 13 code · 5 blank · 39 comment · 0 complexity · 13a781d190584eac772512c2a40a75ff 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 interface.
  7. /// </summary>
  8. public interface IContainer
  9. {
  10. /// <summary>
  11. /// The list of services currently available inside the container.
  12. /// </summary>
  13. IEnumerable<IServiceInfo> AvailableServices { get; }
  14. /// <summary>
  15. /// Determines whether or not a container will throw an exception
  16. /// if the requested service is not found.
  17. /// </summary>
  18. bool SuppressErrors { get; set; }
  19. /// <summary>
  20. /// Adds an <see cref="IFactory" /> instance and associates it
  21. /// with the given <paramref name="serviceType">service type</paramref>.
  22. /// </summary>
  23. /// <param name="serviceType">The service type to associate with the factory</param>
  24. /// <param name="additionalParameterTypes">The list of additional parameters that this factory type will support.</param>
  25. /// <param name="factory">The <see cref="IFactory" /> instance that will be responsible for creating the service instance</param>
  26. void AddFactory(Type serviceType, IEnumerable<Type> additionalParameterTypes, IFactory factory);
  27. /// <summary>
  28. /// Determines whether or not the container can create
  29. /// the given <paramref name="serviceType">service type</paramref>.
  30. /// </summary>
  31. /// <param name="serviceType">
  32. /// The type of service used to determine whether or not the given service can actually be
  33. /// created
  34. /// </param>
  35. /// <param name="additionalParameterTypes">The list of additional parameters that this factory type will support.</param>
  36. /// <returns>A <see cref="bool">boolean</see> value that indicates whether or not the service exists.</returns>
  37. bool Contains(Type serviceType, IEnumerable<Type> additionalParameterTypes);
  38. /// <summary>
  39. /// Causes the container to instantiate the service with the given
  40. /// <paramref name="serviceType">service type</paramref>. If the service type cannot be created, then an
  41. /// exception will be thrown if the <see cref="SuppressErrors" /> property
  42. /// is set to false. Otherwise, it will simply return null.
  43. /// </summary>
  44. /// <param name="serviceType">The service type to instantiate.</param>
  45. /// <param name="additionalArguments">The additional arguments that will be used to instantiate the service type.</param>
  46. /// <returns>
  47. /// If successful, it will return a service instance that is compatible with the given type;
  48. /// otherwise, it will just return a null value.
  49. /// </returns>
  50. object GetService(Type serviceType, params object[] additionalArguments);
  51. }
  52. }