Reputation: 47
i'm building a simple winforms app, i'm using n-Tier Architecture, Dependecy Injection (with Simple Injector), Entity Framework Code First, Repository and Unit Of Work patterns.
Basically, i know that i can register objects on my Container on the app's entry point (Program.cs), but that only works for objects accessible from the UI, which rules out Data Access Layer objects.
So, how can i register objects from the Business Logic Layer since it's a class library.
Thanks in advance.
Upvotes: 1
Views: 1607
Reputation: 28737
You need to make a distinction between a dependency and a reference.
You're correct in saying that your UI should not have a dependency on your DataAccessLayer. But that means it shouldn't be hard-wired to SQL Server code (to give an example). It doesn't mean however that you can't reference that project.
To solve your problem, just reference all the projects from your UI (which will be the entry point for your application).
The fact is that if you create references like this: UI => Business Logic => Data Access, you're also referencing the data layer from the UI, just indirectly.
I've written a post about exactly this which explains it in further detail:
https://www.kenneth-truyers.net/2013/05/12/the-n-layer-myth-and-basic-dependency-injection/
Upvotes: 2