I am trying to update some code from using DynamicProxy to DynamicProxy2. In particular we where using DynamicProxy to provide a mixin of two classes. The setup is something like this:
public interface IHasShape
{
string Shape { get; }
}
public interface IHasColor
{
string Color { get; }
}
public interface IColoredShape : IHasShape, IHasColor
{
}
Then assuming some obvious concrete implementations of IHasShape and IHasColor we would create a mixin like this:
public IColoredShape CreateColoredShapeMixin(IHasShape shape, IHasColor color)
{
ProxyGenerator gen = new ProxyGenerator();
StandardInterceptor interceptor = new StandardInterceptor();
GeneratorContext context = new GeneratorContext();
context.AddMiniInstance(color);
return gen.CreateCustomProxy(typeof(IColoredShape), intercetor, shape, context);
}
There are no concrete implementations of IColoredShape except as a result of the proxy creation. The StandardInterceptor takes calls on the IColoredShape object and delegates them to either the 'shape' or 'color' objects as appropriate.
However, I've been playing around with the new DynamicProxy2 and can't find the equivalent implementation.