Class GameServiceContainer
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
Exceptions
- ArgumentNullException
If
type
orprovider
is
.null
- ArgumentException
If
provider
cannot be assigned totype
.
AddService<T>(T)
Add a service provider to this container.
public void AddService<T>(T provider)
Parameters
provider
TThe 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
TypeThe type of the service.
Returns
- object
A service provider for the service of the specified type or
if no suitable service provider is registered in this container.null
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
if no suitable service provider is registered in this container.null
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
TypeThe type of the service to remove.
Exceptions
- ArgumentNullException
If the specified type is
.null