Thanks, it worked.
public IInterceptor[] SelectInterceptors(Type type, MethodInfo method,
IInterceptor[] interceptors)
{
var _new = interceptors.OrderBy(i => i is ValidationInterceptor ? 0 :
1).ToArray();
return _new;
}
Then, I'd to change my interceptors a little bit, each one now calls Proceed
before doing anything else. This way ValidationInterceptor proceeds to
NotifierInterceptor, which in turn proceed to real code, then
NotifierInterceptor does what it have to do and eventually
ValidationInterceptor (which can throw exceptions).
Will pay attention whenever I put a new interceptor, to not affect the others.
Thanks again.
-----Mensagem original-----
De: [email protected]
[mailto:[email protected]] Em nome de Krzysztof Kozmic
Enviada em: quinta-feira, 22 de julho de 2010 20:13
Para: [email protected]
Assunto: Re: Controlling order of interceptor invocation
use IInterceptorSelector
On 23/07/2010 12:29 AM, André wrote:
> Hi!
>
> I'm creating proxies this way:
>
> public static T Build<T>() where T : class, new()
> {
> var notifierInterceptor = new NotifierInterceptor();
> var validationInterceptor = new ValidationInterceptor();
>
> var proxy =
> _generator.CreateClassProxy<T>(validationInterceptor,
> notifierInterceptor);
> return proxy;
> }
>
> I've found that, when validationInterceptor executes and throws an
> error, the other interceptor doesn't gets a chance to run. I've tried
> to reverse the order that they're passed to method:
>
> var proxy =
> _generator.CreateClassProxy<T>(notifierInterceptor,
> validationInterceptor);
>
> But same thing, validationInterceptor always runs first.
>
> What can I do to handle that?
>
> Thanks
>
>
--
You received this message because you are subscribed to the Google Groups
"Castle Project Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/castle-project-users?hl=en.
--
You received this message because you are subscribed to the Google Groups
"Castle Project Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/castle-project-users?hl=en.