ステートレスエンティティを使用します。ASP.NETGridViewの動作により、既存のオブジェクトのみをラップするプロキシを作成する必要がありました。
この方法でターゲットインスタンスを保持するインターセプターを作成しました。
public class ForwardingInterceptor : IInterceptor
{
private object target;
private Type type;
public ForwardingInterceptor(Type type, object target)
{
this.target = target;
}
public void Intercept(IInvocation invocation)
{
invocation.ReturnValue = invocation.Method.Invoke(this.target, invocation.Arguments);
}
}
次に、ラッパープロキシを簡単に作成できます。
this.proxyGenerator.CreateClassProxy(type, new ForwardingInterceptor(type, target));