初始化入口

在AbpKernelModule类中,通过UnitOfWorkRegistrar.Initialize(IocManager) 方法去初始化

Abp Uow 设计

 1 /// <summary>
 2     /// This class is used to register interceptor for needed classes for Unit Of Work mechanism.
 3     /// </summary>
 4     internal static class UnitOfWorkRegistrar
 5     {
 6         /// <summary>
 7         /// Initializes the registerer.
 8         /// </summary>
 9         /// <param name="iocManager">IOC manager</param>
10         public static void Initialize(IIocManager iocManager)
11         {
12             iocManager.IocContainer.Kernel.ComponentRegistered += ComponentRegistered;
13         }
14 
15         private static void ComponentRegistered(string key, IHandler handler)
16         {
17             if (UnitOfWorkHelper.IsConventionalUowClass(handler.ComponentModel.Implementation))
18             {
19                 //Intercept all methods of all repositories.
20                 handler.ComponentModel.Interceptors.Add(new InterceptorReference(typeof(UnitOfWorkInterceptor)));
21             }
22             else if (handler.ComponentModel.Implementation.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Any(UnitOfWorkHelper.HasUnitOfWorkAttribute))
23             {
24                 //Intercept all methods of classes those have at least one method that has UnitOfWork attribute.
25                 //TODO: Intecept only UnitOfWork methods, not other methods!
26                 handler.ComponentModel.Interceptors.Add(new InterceptorReference(typeof(UnitOfWorkInterceptor)));
27             }
28         }
29     }
UnitOfWorkRegistrar

相关文章:

  • 2022-12-23
  • 2021-10-29
  • 2021-04-29
  • 2021-12-03
  • 2022-12-23
  • 2022-02-19
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-13
  • 2021-07-29
  • 2022-12-23
  • 2022-02-01
  • 2021-07-12
  • 2021-05-18
相关资源
相似解决方案