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

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -