views:

16

answers:

1

Hi I was thinking about such case:

 public class MyService {

        private IList<Entity> data;

        public virtual IList<Entity> GetData()
        {
            return data;
        }        

        public virtual IList<Entity> GetDataAdvanced()
        {
           return GetData();
        }
  } 

Consider a situation when i have a proxy of this class (e.g logging interceptor). The problem is: with GetData() method will GetDataAdvanced() use: the proxied one or normal? After a test i looks like it is not using proxy. I was wondering if it is possible to change such behavior ?

Thanks for help.

Kuba

+1  A: 

This depends. When you're using ProxyGenerator.CreateClassProxy() or ProxyGenerator.CreateInterfaceProxyWithoutTarget(), the proxy will be a child class of your original class which is instantiated and then, yes, GetData() will actually call the proxy.

If you however are using ProxyGenerator.CreateInterfaceProxyWithTarget() and you're providing your own instance of MyService, the proxy is only a wrapper from the outside and internal calls like the GetData() call will not go through the proxy.

Pieter
thx - good to know that, one more thing - is there any way to specify what proxy generation strategy to use (without or with target) when registering componenets with windsor container ?
Sorry, no experience with Windsor.
Pieter