public void Intercept(IInvocation invocation)
        {
            List<IAspect> handlers = new List<IAspect>();

            foreach (AdviceHandler advice in advices) {
                if (advice.IsPointcutMethod(invocation.Method, kernel)) {
                    handlers.AddRange(advice.CreateAspects(kernel));
                }
            }
            foreach (IAspect handler in handlers) {
                //note that if it halts, the handler is responsbile to set
                //the return value correctly.
                if (handler.PreCall(invocation) == MethodVoteOptions.Halt)
                    return;
            }
            try {
                invocation.Proceed();

            }
            catch (Exception e) {
                AspectExceptionAction exceptionAction = new AspectExceptionAction() {IgnoreException=false};
                foreach (IAspect handler in handlers) {
                    handler.OnException(invocation, e, exceptionAction);
                }
                if (!exceptionAction.IgnoreException) throw;
            }
            AspectReturnValue retvalue = new AspectReturnValue() { Original = invocation.ReturnValue };
            foreach (IAspect handler in handlers) {
                handler.PostCall(invocation, retvalue);
            }
            invocation.ReturnValue = retvalue.GetReturnValue();
        }
        public void Intercept(IInvocation invocation)
        {
            List <IAspect> handlers = new List <IAspect>();

            foreach (AdviceHandler advice in advices)
            {
                if (advice.IsPointcutMethod(invocation.Method, kernel))
                {
                    handlers.AddRange(advice.CreateAspects(kernel));
                }
            }
            foreach (IAspect handler in handlers)
            {
                //note that if it halts, the handler is responsbile to set
                //the return value correctly.
                if (handler.PreCall(invocation) == MethodVoteOptions.Halt)
                {
                    return;
                }
            }
            try {
                invocation.Proceed();
            }
            catch (Exception e) {
                AspectExceptionAction exceptionAction = new AspectExceptionAction()
                {
                    IgnoreException = false
                };
                foreach (IAspect handler in handlers)
                {
                    handler.OnException(invocation, e, exceptionAction);
                }
                if (!exceptionAction.IgnoreException)
                {
                    throw;
                }
            }
            AspectReturnValue retvalue = new AspectReturnValue()
            {
                Original = invocation.ReturnValue
            };

            foreach (IAspect handler in handlers)
            {
                handler.PostCall(invocation, retvalue);
            }
            invocation.ReturnValue = retvalue.GetReturnValue();
        }
 public void PostCall(CastleIInvocation invocation, AspectReturnValue returnValue)
 {
     //override the return value
     returnValue.WrappedReturnValue = "Other";
 }