IIocRegistrar.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using System;
  2. using System.Reflection;
  3. namespace Abp.Dependency
  4. {
  5. /// <summary>
  6. /// Define interface for classes those are used to register dependencies.
  7. /// </summary>
  8. public interface IIocRegistrar
  9. {
  10. /// <summary>
  11. /// Adds a dependency registrar for conventional registration.
  12. /// </summary>
  13. /// <param name="registrar">dependency registrar</param>
  14. void AddConventionalRegistrar(IConventionalDependencyRegistrar registrar);
  15. /// <summary>
  16. /// Registers types of given assembly by all conventional registrars. See <see cref="IocManager.AddConventionalRegistrar"/> method.
  17. /// </summary>
  18. /// <param name="assembly">Assembly to register</param>
  19. void RegisterAssemblyByConvention(Assembly assembly);
  20. /// <summary>
  21. /// Registers types of given assembly by all conventional registrars. See <see cref="IocManager.AddConventionalRegistrar"/> method.
  22. /// </summary>
  23. /// <param name="assembly">Assembly to register</param>
  24. /// <param name="config">Additional configuration</param>
  25. void RegisterAssemblyByConvention(Assembly assembly, ConventionalRegistrationConfig config);
  26. /// <summary>
  27. /// Registers a type as self registration.
  28. /// </summary>
  29. /// <typeparam name="T">Type of the class</typeparam>
  30. /// <param name="lifeStyle">Lifestyle of the objects of this type</param>
  31. void Register<T>(DependencyLifeStyle lifeStyle = DependencyLifeStyle.Singleton)
  32. where T : class;
  33. /// <summary>
  34. /// Registers a type as self registration.
  35. /// </summary>
  36. /// <param name="type">Type of the class</param>
  37. /// <param name="lifeStyle">Lifestyle of the objects of this type</param>
  38. void Register(Type type, DependencyLifeStyle lifeStyle = DependencyLifeStyle.Singleton);
  39. /// <summary>
  40. /// Registers a type with it's implementation.
  41. /// </summary>
  42. /// <typeparam name="TType">Registering type</typeparam>
  43. /// <typeparam name="TImpl">The type that implements <see cref="TType"/></typeparam>
  44. /// <param name="lifeStyle">Lifestyle of the objects of this type</param>
  45. void Register<TType, TImpl>(DependencyLifeStyle lifeStyle = DependencyLifeStyle.Singleton)
  46. where TType : class
  47. where TImpl : class, TType;
  48. /// <summary>
  49. /// Registers a type with it's implementation.
  50. /// </summary>
  51. /// <param name="type">Type of the class</param>
  52. /// <param name="impl">The type that implements <paramref name="type"/></param>
  53. /// <param name="lifeStyle">Lifestyle of the objects of this type</param>
  54. void Register(Type type, Type impl, DependencyLifeStyle lifeStyle = DependencyLifeStyle.Singleton);
  55. /// <summary>
  56. /// Checks whether given type is registered before.
  57. /// </summary>
  58. /// <param name="type">Type to check</param>
  59. bool IsRegistered(Type type);
  60. /// <summary>
  61. /// Checks whether given type is registered before.
  62. /// </summary>
  63. /// <typeparam name="TType">Type to check</typeparam>
  64. bool IsRegistered<TType>();
  65. }
  66. }