0

I am working on a side-project involving a small self-hosted Nancy server for the local network to remotely control a media player. To enable support for multiple players I implemented a simple plugin mechanism like it was outlined here: http://code.msdn.microsoft.com/windowsdesktop/Creating-a-simple-plugin-b6174b62

The dynamic loading and execution works great, but the problem I am running into is how to tell TinyIoC which plugin implementation to use. At the moment I have a subdirectory named plugins where the .dlls are stored and at startup TinyIoC discovers the one test dll in this directory and wires up the dependency without me choosing anything explicitly.

I found the method Bootstrapper.ConfigureApplicationContainer to be the place to do DI configuration but since I want to use a dynamic system and do not have the server project a reference to all plugin assemblies that is not sufficient in my case.

Is this even possible with TinyIoC or do I need to look for another IoC container?

Thanks a lot in advance

MrFloya
  • 137
  • 2
  • 10

1 Answers1

0

Not sure if this suits your needs, but it's suggestion anyway: You could have each of the plugins do its own container configuration, by having each of them provide an implementation of IRegistrations in plugins .dll.

Nancy will pick implmentations of IRegistrations up automatically - as long the assemblies are loaded at startup - and execute them during application startup.

Alternatively you could scan the plugins directory yourself in the Bootstrapper.ConfigureApplicationContainer method and scan the plugin .dlls for either IRegistrations or your own custom hook.

Christian Horsdal
  • 4,914
  • 23
  • 24