I'm wondering what to do with dependency injection considering the following architecture.
I have 3 projects
MyProject.UI
MyProject.Business
MyProject.SomeOtherThing
StructureMap is being used for dependency injection in MyProject.UI.
public static class Bootstrapper
{
public static void Run()
{
ControllerBuilder.Current.SetControllerFactory(new StructureMapControllerFactory());
ObjectFactory.Initialize(x =>
{
x.For<ISomeClass>().Use<SomeClass>();
}
}
}
My question is, the MyProject.SomeOtherThing has some classes in it that are being consumed by MyProject.Business. These classes are set up to use DI.
namespace MyProject.SomeProject
{
public SomeClass
{
public ISomeDependency SomeDependency { get; set; }
public SomeClass (ISomeDependency someDependency)
{
SomeDependency = someDependency;
}
}
}
The business layer consumes the class and exposes a service that use SomeClass called SomeService.
In order for the DI registration to work, MyProject.UI has to have a reference to MyProject.SomeOtherThing.
I'd like to avoid that. Ideally the UI project would only have a reference to MyProject.Business.
What's the best way to handle this situation? Is it to move DI configurations into MyProject.Business? Or is there something else I'm missing?
Thanks!