Ejemplo n.º 1
0
        void Kernel_ComponentRegistered(string key, IHandler handler)
        {
            //Intercept all methods of all repositories.
            if (UnitOfWorkHelper.IsRepositoryClass(handler.ComponentModel.Implementation))
            {
                handler.ComponentModel.Interceptors.Add(new InterceptorReference(typeof(UnitOfWorkInterceptor)));
            }

            //Intercept all methods of classes those have at least one method that has UnitOfWork attribute.
            foreach (var method in handler.ComponentModel.Implementation.GetMethods())
            {
                if (UnitOfWorkHelper.HasUnitOfWorkAttribute(method))
                {
                    handler.ComponentModel.Interceptors.Add(new InterceptorReference(typeof(UnitOfWorkInterceptor)));
                    return;
                }
            }
        }
Ejemplo n.º 2
0
 private static bool RequiresDbConnection(MethodInfo methodInfo)
 {
     return(UnitOfWorkHelper.HasUnitOfWorkAttribute(methodInfo) || UnitOfWorkHelper.IsRepositoryMethod(methodInfo));
 }