I understand that your Cache
attribute is MethodInterceptionAspect
. During interception your aspect's OnInvoke
code is actually executed first and then it can continue with executing your original method. It seems that what you're asking about is the opposite - calling OnInvoke
back from the original Get
method. This is of course is not possible.
You can perform some refactoring by creating a new method with all the parameters that define the caching key. Then inside your OnInvoke
method you can just use MethodInterceptionArgs.Arguments to build the caching key.
private T Get()
{
int id = 5;
return GetInternal(id);
}
[Cache]
private T GetInternal(int id)
{
return GetCustomerService(id);
}