views:

465

answers:

0

Hi There!

Right now I'm having a problem with Unity InterfaceInterceptor because it will fail when constructing the dynamic type. My classes and interfaces are something like this:


public interface IService<T>
{
     void Save(T entity);
}

public interface IOrderService : IService<Order>
{
    void GetCustomerOrders(Customer customer);
}

public abstract class ServiceBase<T> : IService<T>
{
    public void Save(T entity)
    {
          //Some code that saves a generic entity
    }
}

public class OrderService : IOrderService, ServiceBase<Order>
{
   public void GetCustomerOrders(Customer customer)
   {
        //Some code that gets customer orders
   }
}

My Unity configuration code is as follows:


IUnityContainer container = new UnityContainer();
container.RegisterType<IOrderService, OrderService>();

container.AddNewExtension<Interception>()
                .Configure<Interception>()
                .SetDefaultInterceptorFor<IOrderService>(new InterfaceInterceptor());

var svc = container.Resolve<IOrderService>();


It fails with a "Method 'Save' in type .... does not have an implementation".

Any ideas how to tell Unity to get my type??

Thanks in advance!