using LinFu.AOP.Interfaces;
using LinFu.Proxy;
using LinFu.Proxy.Interfaces;
using NUnit.Framework;
namespace LinFu.UnitTests {
[TestFixture]
public class ProxyInjectionTest {
public class Interceptor : IInterceptor {
public object Intercept(IInvocationInfo info) {
//how can I call the target method on the base class??
//In DP2 there is always invocation.Proceed(), why do I
have to code the reflection stuff by myself?
//this is not really an option, I don't want to use the
interceptor for transporting the base target.
//return info.TargetMethod.Invoke(_target,
info.Arguments);
}
//private readonly object[] _contructorArgs;
//public Interceptor(params object[] contructorArgs)
//{
// _contructorArgs = contructorArgs;
//}
}
[Test]
public void Test() {
IProxyFactory factory = new ProxyFactory();
//Problem: CreateProxy doesn't support constructor arguments,
only a default constructor is created.
var c = factory.CreateProxy<Class1>(new Interceptor());
//there should be something like this: ...params object[] args
//var c = factory.CreateProxy<Class1>(new Interceptor(), new
Class2(), new Class3());
//do this via interceptor is not really nice
//var c = factory.CreateProxy<Class1>(new Interceptor(new
Class2(), new Class3()));
c.Execute();
}
}
public class Class1 {
private readonly Class2 _class2;
private readonly Class3 _class3;
public Class1(Class2 class2, Class3 class3) {
_class2 = class2;
_class3 = class3;
}
public virtual void Execute() {
_class2.Execute();
_class3.Execute();
}
}
public class Class2 {
public virtual void Execute() {}
}
public class Class3 {
public virtual void Execute() {}
}
}
Original issue reported on code.google.com by familie....@googlemail.com on 23 Jun 2009 at 5:31
Original issue reported on code.google.com by
familie....@googlemail.com
on 23 Jun 2009 at 5:31