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 <code class="paramref">type</code> or <code class="paramref">provider</code> isnull.
- ArgumentException
If
providercannot be assigned totype.
AddService<T>(T)
Add a service provider to this container.
public void AddService<T>(T provider)
Parameters
providerTThe provider of the service.
Type Parameters
TThe type of the service.
Exceptions
- ArgumentNullException
If <code class="paramref">provider</code> isnull.
GetService(Type)
Get a service provider for the service of the specified type.
public object GetService(Type type)
Parameters
typeTypeThe type of the service.
Returns
- object
A service provider for the service of the specified type ornullif 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 ornullif no suitable service provider is registered in this container.
Type Parameters
TThe 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
typeTypeThe type of the service to remove.
Exceptions
- ArgumentNullException
If the specified type is
null.