public void Intercept(Castle.DynamicProxy.IInvocation invocation)
 {
     if (!_ignoreMethods.Contains(invocation.Method.Name))
     {
         if (Log) { System.Console.WriteLine("{0}.{1} {2}", invocation.TargetType.Name, invocation.Method.Name, string.Join(" ", invocation.Arguments)); }
     }
     invocation.Proceed();
     if (!_ignoreMethods.Contains(invocation.Method.Name))
     {
         if (MillisecondsPause > 0) { Pause(); }
     }
 }
        public void Intercept(Castle.DynamicProxy.IInvocation invocation)
        {
            if (NHibernateUnitOfWork.Current != null || !RequiresDbConnection(invocation.MethodInvocationTarget))
            {
                invocation.Proceed();
                return;
            }

            try
            {
                NHibernateUnitOfWork.Current = new NHibernateUnitOfWork(_sessionFactory);
                NHibernateUnitOfWork.Current.BeginTransaction();

                try
                {
                    invocation.Proceed();
                    NHibernateUnitOfWork.Current.Commit();
                }
                catch
                {
                    try
                    {
                        NHibernateUnitOfWork.Current.Rollback();
                    }
                    catch
                    {

                    }

                    throw;
                }
            }
            finally
            {
                NHibernateUnitOfWork.Current = null;
            }
        }
예제 #3
0
		public void Intercept(Castle.Core.Interceptor.IInvocation invocation)
		{
			IMethodInterceptor[] interceptors = ObtainAdvicesForMethod(invocation.Method,
			                                                           invocation.InvocationTarget, invocation.Arguments);

			if (interceptors.Length == 0)
			{
				// Nothing to intercept. 
				// Get on with it!
				invocation.Proceed();
				return;
			}

			InvocationComposite alliance_invocation = new InvocationComposite(
				interceptors, invocation, invocation.Arguments);

			object retval = alliance_invocation.Proceed();
			invocation.ReturnValue = retval;
		}