Interceptor
public class CachingInterceptor : IInterceptor
{
public void Intercept(IInvocation invocation)
{
// code comes here....
}
}
Business Layer
public class Business : IBusiness
{
public void Add(string a)
{
var t= GetAll();
// code comes here....
}
[CacheAttribute]
public string GetAll()
{
// code comes here....
}
}
Class
public class JustForTest
{
public JustForTest(IBusiness business)
{
//if GetAll is invoked directly caching works fine.
business.GetAll();
//if GetAll is invoked over Add method caching doesn't work.
business.Add();
}
}
add method calls GetAll method. If I invoke GetAll method directly, caching works. If Add method calls GetAll Method, caching doesn't work.
Thank You for helping.
Business
instance from thecontainer
and notnew
it up yourself. – Elenoraelenore