Static Access To Multiple Instance Variable

Posted by Qua on Stack Overflow See other posts from Stack Overflow or by Qua
Published on 2010-04-15T21:11:37Z Indexed on 2010/04/15 21:23 UTC
Read the original article Hit count: 305

Filed under:
|
|
|

I have a singleton instance that is referenced throughout the project which works like a charm. It saves me the trouble from having to pass around an instance of the object to every little class in the project. However, now I need to manage multiple instances of the previous setup, which means that the singleton pattern breaks since each instance would need it's own singleton instance.

What options are there to still maintain static access to the singleton? To be more specific, we have our game engine and several components and plugins reference the engine through a static property. Now our server needs to host multiple game instances each having their own engine, which means that on the server side the singleton pattern breaks.

I'm trying to avoid all the classes having the engine in the constructor.

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET