Question

I have a multi-tier console application with the following components: - data access layer - domain layer - uses data repository classes defined in the data access layer - engine - this contains the entry point for the application and uses the domain layer classes, orchestrating the operations

The data access layer classes and the domain layer classes implement a set of interfaces. How do you recommend that I do DI? Do I need a reference to Ninject in both my domain classes and my engine classes, is there any other way to do the binding in a single place? What would be the best pattern to do this.

I'm just starting out with DI and Ninject so any help, examples and explanations would be very helpful.

Was it helpful?

Solution

I will write you a simple example and add it on my github. Should be there in 30 minutes or so. Will post the link to it here a.s.a.p

EDIT: Here you have the sample project: ConsoleApplicationNinject

EDIT: And this is where you´ll do the binding. https://github.com/codeplanner/ConsoleAppNinject/blob/master/ConsoleAppNinject/Ninject/ServiceModule.cs

OTHER TIPS

Do I need a reference to Ninject in both my domain classes and my engine classes, is there any other way to do the binding in a single place? What would be the best pattern to do this.

As close as possible to the application's entry point.

This place is called the Composition Root.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top