What Does A GameServiceContainer Do?

I was poking around using custom content managers, and i found that in both of the overloads, it needs a GameSerciveContainer after looking at the GSC’s source on github, i am unable to fathom what it’s purpose is.
Thanks in advance for all and any support
PS: I put it in general as i idin’t know where to put it

A GameServiceContainer acts as a collection of various game services that other parts of the game code may require. For example, the GraphicsDevice adds itself to the services container so that other modules, such as the ContentManager, can access the GraphicsDevice.

IGraphicsDeviceService graphicsDeviceService = (IGraphicsDeviceService)serviceProvider.GetService(typeof(IGraphicsDeviceService));
GraphicsDevice graphicsDevice = graphicsDeviceService.GraphicsDevice;

Your code can also add objects to the GameServiceContainer for use by other modules in your code.

The GameServiceContainer is an implementation of the “service provider” design pattern. A few years ago, my colleague wrote a few blog posts about this pattern and how it can help to simplify your XNA game code.

The articles are archived here: The Service Provider Pattern for Games

1 Like

Thanks for the response @KonajuGames. just about to read the posts now @mgarstenauer