Creating a dynamic lock proxy

I am implementing a project where my layer will be between the client and the server, and any objects that I get from the server, I would wrap it in a transparent proxy server and provide it to the client, so I can track what has changed in the object, therefore, keeping it back, I would only send the changed information.

I looked at the dynamic lock proxy, linfu, although they can generate a proxy type, but they cannot use existing objects and wrap them.

It's amazing if this is possible to do with these frames, or if there are other frameworks that allow this ...

+5
source share
2 answers

Dynamic Proxy 3.x , , , .

+4

, - ASP.NET GridView -, .

, :

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));
+5

All Articles