ServiceContainer Class
Definition
The ServiceContainer is a built-in service that manages the list of services. You can only add services to it, removing or replacing services is not supported because many designers depend on keeping their services available.
Inheritance
Implements
Syntax
public sealed class ServiceContainer : IServiceProvider
Properties
AllServices | Gets a collection of all registered services. |
Component | Gets the IComponentService. Throws an exception if the service is not found. |
DesignPanel | Gets the IDesignPanel. Throws an exception if the service is not found. |
ExtensionManager | Gets the ExtensionManager. Throws an exception if the service is not found. |
Selection | Gets the ISelectionService. Throws an exception if the service is not found. |
Tool | Gets the IToolService. Throws an exception if the service is not found. |
View | Gets the ViewService. Throws an exception if the service is not found. |
Methods
AddOrReplaceService(Type, Object) | Adds a new service to the container or Replaces a existing one. |
AddService(Type, Object) | Adds a new service to the container. |
GetRequiredService<T>() | Gets a required service. Never returns null; instead a ServiceRequiredException is thrown when the service cannot be found. |
GetService(Type) | Gets the service object of the specified type. Returns null when the service is not available. |
GetService<T>() | Gets the service object of the type T. Returns null when the service is not available. |
RunWhenAvailable<T>(Action<T>) | Subscribes to the service of type T. serviceAvailableAction will be called after the service gets available. If the service is already available, the action will be called immediately. |