ProxyFoo is currently v0.x.x, which means that the API is subject to change.

Intercept Proxies

Intercept proxies allow for the interception of interface methods on an existing type. This is similar to what is done in DynamicProxy although based on the contract of the interface.

Usage

An intercept proxy is created with the following static method call:

using ProxyFoo;

public class SomeClass : IDisposable
{
    void IDisposable.Dispose() { }
}

public class InterceptorClass : IDisposable
{
    IDisposable _target;

    public InterceptorClass( IDisposable target ) { }       

    public Dispose()
    {
        // Do something before
        _target.Dispose();
        // Do something after
    }
}

var proxyType = ProxyModule.Default.GetTypeFromProxyClassDescriptor(
    new ProxyClassDescriptor(
        typeof(SomeClass),
        new InterceptMixin(typeof(InterceptorClass))));

var result = (SomeClass)Activator.CreateInstance(proxyType);
It is anticipated that this feature will be expanded to include a better api for creation, support for abstract classes, and possibly more dynamic forms of interception. Feedback is welcome!