What design pattern should I be utilizing if I require a group of singleton classes to be searchable/retrievable? -
i need have single instances of bunch of classes in project. however, need them searchable/retrievable (like array). design pattern should utilizing?
i'm not sure if understand correctly, think maybe need dependency injection container. take inversion of control/dependency injection patterns.
microsoft patterns &practices provides implementation of di container called unity. there other open source projects castle windsor , others
you can register types in container, specifying, example, want types singleton:
iunitycontainer container = new unitycontainer(); container.registertype<myclass>(new containercontrolledlifetimemanager()); ... var mysingletontype = container.resolve<myclass>(); // calls method // return same instance ioc/di more this, hope example useful start point.
Comments
Post a Comment