2

Is it possible to intercept non-public methods with Castle Dynamic Proxy?

Will something like this work to intercept non-public members?

 base.BootStrapContainer.Register(
                    Classes.FromAssemblyNamed(referencedAssembly)
                           .IncludeNonPublicTypes()
                           .Pick()
                           .Configure(component => component.Interceptors<TracingAspect>()));

OutOFTouch
  • 1,017
  • 3
  • 13
  • 30
  • 3
    Take a step back and look at the design of your application. – Steven Jan 04 '13 at 15:52
  • Can you elaborate please? – OutOFTouch Jan 04 '13 at 20:52
  • As far I know, members can't be intercepted unless virtual, interface members are virtual by default. I am asking the question in first place for confirmation of that, but your comment is really quite not helpful, because you assumed I designed the application. – OutOFTouch Jan 04 '13 at 21:01
  • I do agree with your answer here though about design, http://stackoverflow.com/questions/633710/what-is-the-best-implementation-for-aop-in-net/14062850#14062850 – OutOFTouch Jan 04 '13 at 21:12

1 Answers1

1

No. Only members that are public to dynamic proxy can be intercepted.

Krzysztof Kozmic
  • 27,267
  • 12
  • 73
  • 115