Possible Duplicate:
Injecting data to a WCF service
I have a WCF service that looks like this: (Service-contract attributes omitted for clarity)
public interface IMyService
{
void LoadBulkData(LoadRequest request);
}
public class MyService : IMyService
{
IUnityContainer unity = new UnityContainer();
IDataProvider provider;
public MyService()
{
unity.LoadConfiguration();
provider = unity.Resolve<IDataProvider>();
}
public void LoadBulkData(LoadRequest request)
{
// ...
}
}
As per company policy, Microsoft Unity must be used for DI/IoC. Because this is WCF, I can't use constructor injection because the service implementation must use the default, parameterless constructor.
In particular, I don't like using Unity to resolve the dependency in the constructor. Does anyone know of a way around this? Also, is there a pattern out there that might better suit my needs here?