EDN Admin
Well-known member
I can use the ContextBoundObject to intercept method calls to inject preprocessors and post processors. The following links explain the process for doing this better than I can:
http://blogs.msdn.com/geoffda/archive/2007/11/07/using-a-custom-proxy-for-interception.aspx
http://people.apache.org/~hammett/articles/dotnettransactions.html
http://www.codeproject.com/KB/cs/aspectintercept.aspx
The problem Im having is that I cannot intercept methods called from within the intercepted class. That is, if I instantiate class A and call Method1, it will get intercepted, but if Method1 in turn calls Method2, Method2 wont be intercepted.
How can I intercept Method2?
Heres a piece of code to further clarify the situation:static void Main(string[] args)
{
TestClass tc = new TestClass();
String name = tc.GetName(); // GetName will be intercepted
Console.WriteLine("Hello " + name);
}
[InterceptorProxy]
public class TestClass : ContextBoundObject
{
public string GetName()
{
DoSomethingELSE(); // DoSomethingELSE will NOT be intercepted
return "World!";
}
public void DoSomethingELSE()
{
// Do something
}
}
View the full article
http://blogs.msdn.com/geoffda/archive/2007/11/07/using-a-custom-proxy-for-interception.aspx
http://people.apache.org/~hammett/articles/dotnettransactions.html
http://www.codeproject.com/KB/cs/aspectintercept.aspx
The problem Im having is that I cannot intercept methods called from within the intercepted class. That is, if I instantiate class A and call Method1, it will get intercepted, but if Method1 in turn calls Method2, Method2 wont be intercepted.
How can I intercept Method2?
Heres a piece of code to further clarify the situation:static void Main(string[] args)
{
TestClass tc = new TestClass();
String name = tc.GetName(); // GetName will be intercepted
Console.WriteLine("Hello " + name);
}
[InterceptorProxy]
public class TestClass : ContextBoundObject
{
public string GetName()
{
DoSomethingELSE(); // DoSomethingELSE will NOT be intercepted
return "World!";
}
public void DoSomethingELSE()
{
// Do something
}
}
View the full article