Table of Contents

Class GameServiceContainer

Namespace
Microsoft.Xna.Framework
Assembly
MonoGame.Framework.dll

A container for services for a Game.

public class GameServiceContainer : IServiceProvider
Inheritance
GameServiceContainer
Implements
Inherited Members

Constructors

GameServiceContainer()

Create an empty GameServiceContainer.

public GameServiceContainer()

Methods

AddService(Type, object)

Add a service provider to this container.

public void AddService(Type type, object provider)

Parameters

type Type

The type of the service.

provider object

The provider of the service.

Exceptions

ArgumentNullException

If type or provider is

null
.
ArgumentException

If provider cannot be assigned to type.

AddService<T>(T)

Add a service provider to this container.

public void AddService<T>(T provider)

Parameters

provider T

The provider of the service.

Type Parameters

T

The type of the service.

Exceptions

ArgumentNullException

If provider is

null
.

GetService(Type)

Get a service provider for the service of the specified type.

public object GetService(Type type)

Parameters

type Type

The type of the service.

Returns

object

A service provider for the service of the specified type or

null
if no suitable service provider is registered in this container.

Exceptions

ArgumentNullException

If the specified type is

null
.

GetService<T>()

Get a service provider of the specified type.

public T GetService<T>() where T : class

Returns

T

A service provider of the specified type or

null
if no suitable service provider is registered in this container.

Type Parameters

T

The type of the service provider.

RemoveService(Type)

Remove the service with the specified type. Does nothing no service of the specified type is registered.

public void RemoveService(Type type)

Parameters

type Type

The type of the service to remove.

Exceptions

ArgumentNullException

If the specified type is

null
.