1

I have a solution which contains a core client library and a platform specific client which implements the UI and platform specific operations. It has come about that the core client library contains a reference to a static factory method which needs a platform specific concrete implementation (actually a wrapper around a PCL, which provides a different component per platform) for different targets.

I am using Ninject at various points in the project, and would like to apply the same here. The only complication is that the consumer and the provider are in separate namespaces and separate .vsproj projects.

I was thinking that one way to go about this would be to provide an instantiating service ( a static class with get and set surrounding a static field) which can set the kernel for the core library, once dependancies have been bound in the consuming client. However, I didn't quite know if this was the best practice, or even able to work.

Daniel Park
  • 3,903
  • 4
  • 23
  • 38
  • what do you exactly mean by "which can set the kernel for the core library". How many kernels are you using? Who is currently managing the kernel and who would you ideally like to manage the kernel? Creating bindings in several assemblies while still having only one kernel can be achieved by using NinjectModules. The Application will manage the kernel and define which assemblies to load the modules from. – BatteryBackupUnit Jan 16 '14 at 06:43
  • Maybe https://github.com/ninject/ninject/wiki/Modules-and-the-Kernel and http://stackoverflow.com/questions/7903595/loading-modules-in-all-assemblies-in-ninject provide some helpful information to you? – BatteryBackupUnit Jan 16 '14 at 06:46
  • @BatteryBackupUnit I essentialy want to give the calling application ownership and the client core library to inherit it as such. This way I can bind the factory class in the client application, and then call it from the client core library. I did look briefly into modules, but didn't quite capture its full meaning. Considering two comments here suggest it, I will look more in depth. – Daniel Park Jan 17 '14 at 04:46

0 Answers0