I have been using Unity as my IoC container for a while and I could not find the correct solution for a recurrent problem. I need to create some instances of AuditInsertLogWriter and AuditUpdateLogWriter (they implement IAuditOperationLogWriter interface) depending on the operation argument as you can see bellow:
public IAuditOperationLogWriter Create(Operation operation)
{
    switch (operation)
    {
        case Operation.Insert:
            return UnityContainer.Resolve<AuditInsertLogWriter>();
        case Operation.Update:
            return UnityContainer.Resolve<AuditUpdateLogWriter>();
        default:
            break;
    }
}
The thing is that those instances are complex to create because of their own dependencies. Moreover, I want to remove the dependency with Unity in this factory. So, my question is: how can I achieve that Unity resolves the correct type to create depending on some context?
 
     
    