Interface IServiceRegistry
A service registry is a IServiceProvider that provides methods to register and unregister services.
public interface IServiceRegistry- Extension Methods
Methods
AddService<T>(T)
Adds a service to this ServiceRegistry.
void AddService<T>(T service) where T : classParameters
- serviceT
- The service to add. 
Type Parameters
- T
- The type of service to add. 
Exceptions
- ArgumentNullException
- Thrown when the provided service is null. 
- ArgumentException
- Thrown when a service of the same type is already registered. 
GetOrCreate<T>()
Gets the service object of the specified type, create one if it didn't exist before.
T GetOrCreate<T>() where T : class, IServiceReturns
- T
Type Parameters
- T
- The type of the service to retrieve. 
GetService<T>()
Gets the service object of the specified type.
T? GetService<T>() where T : classReturns
- T
- A service of the requested type, or [null] if not found. 
Type Parameters
- T
- The type of the service to retrieve. 
Remarks
The generic type provided must match the generic type of your initial call to AddService<T>(T)
RemoveService<T>()
Removes the object providing a specified service.
void RemoveService<T>() where T : classType Parameters
- T
- The type of the service to remove. 
Remarks
The generic type provided must match the generic type of your initial call to AddService<T>(T)
RemoveService<T>(T)
Removes the following object from services if it was registered as one.
bool RemoveService<T>(T serviceObject) where T : classParameters
- serviceObjectT
Returns
- bool
- True if the argument was a service, false otherwise 
Type Parameters
- T
- The type of the service to remove. 
Remarks
The generic type provided must match the generic type of your initial call to AddService<T>(T)
Events
ServiceAdded
Occurs when a new service is added to the registry.
event EventHandler<ServiceEventArgs> ServiceAddedEvent Type
ServiceRemoved
Occurs when a service is removed from the registry.
event EventHandler<ServiceEventArgs> ServiceRemoved