The structure of application is that I have two Singletons. One for managing the work, one for managing the SQLite database.
The work manager loads plugins that wish to access the database. Is there anyway to give them access to the Singleton database manager? If I include the database manager class in the plugin dll – would that work?
I know the other way would be to have a field in the plugin interface and set that field on plugin load, I just wanted to know if there was a way to do it and keep my plugin architecture.
Thanks.
EDIT
Restrictions:
- Can’t use external libraries.
- The set of singleton classes that I wish to be accessible from plugins is, and always will be, fixed.
You should have a look at dependency injection containers like Castle Windows, Sprint.NET and Ninject. These will allow you to inject your dependencies automatically or allow your plugins access to your singletons by using the containers.
I’ve used Castle Windsor a lot and can recommend it, but the others mentioned are also used by a lot of developers. Sorry but forget to mention the Microsoft Unity container