Stride

OPEN / CLOSE
  • Features
  • Blog
  • Documentation
  • Community
(icon) Download

  • Discord
  • Facebook
  • Twitter
  • YouTube

LANGUAGE

OPEN / CLOSE
  • English
  • 日本語
    Show / Hide Table of Contents

    ServiceRegistry Class

    Namespace: Stride.Core
    Assembly: Stride.Core.dll

    Base implementation for IServiceRegistry

    System.Object → ServiceRegistry
    Derived from ServiceRegistry:

    public class ServiceRegistry : IServiceRegistry
    Name Description
    Fields
    ServiceRegistryKey
    Methods
    AddService<T>(T)

    Adds a service to this ServiceRegistry.

    GetService<T>()

    Gets the service object of the specified type.

    RemoveService<T>()

    Removes the object providing a specified service.

    Events
    ServiceAdded

    Occurs when a new service is added.

    ServiceRemoved

    Occurs when when a service is removed.

    | Improve this Doc View Source

    Fields


    ServiceRegistryKey

    public static readonly PropertyKey<IServiceRegistry> ServiceRegistryKey
    Field Value
    Type Description
    PropertyKey<IServiceRegistry>
    | Improve this Doc View Source

    Methods


    AddService<T>(T)

    Adds a service to this ServiceRegistry.

    public void AddService<T>(T service)
        where T : class
    Parameters
    Type Name Description
    T service

    The service to add.

    Type Parameters
    Name Description
    T

    The type of service to add.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Service cannot be null

    System.ArgumentException

    Service is already registered with this type


    GetService<T>()

    Gets the service object of the specified type.

    public T GetService<T>()
        where T : class
    Returns
    Type Description
    T

    A service of the requested type, or [null] if not found.

    Type Parameters
    Name Description
    T

    The type of the service to retrieve.


    RemoveService<T>()

    Removes the object providing a specified service.

    public void RemoveService<T>()
        where T : class
    Type Parameters
    Name Description
    T

    The type of the service to remove.

    | Improve this Doc View Source

    Events


    ServiceAdded

    Occurs when a new service is added.

    public event EventHandler<ServiceEventArgs> ServiceAdded
    Event Type
    Type Description
    System.EventHandler<ServiceEventArgs>

    ServiceRemoved

    Occurs when when a service is removed.

    public event EventHandler<ServiceEventArgs> ServiceRemoved
    Event Type
    Type Description
    System.EventHandler<ServiceEventArgs>

    Extension Methods

    ComponentBaseExtensions.DisposeBy<T>(T, ICollectorHolder)
    ComponentBaseExtensions.RemoveDisposeBy<T>(T, ICollectorHolder)
    ServiceRegistryExtensions.GetServiceAs<T>(IServiceRegistry)
    ServiceRegistryExtensions.GetSafeServiceAs<T>(IServiceRegistry)
    ServiceRegistryExtensions.GetServiceLate<T>(IServiceRegistry, Action<T>)
    • Improve this Doc
    • View Source
    In This Article

    Back to top

    Copyright © 2019-2021 .NET Foundation and Contributors
    Supported by the .NET Foundation