docs.unity3d.com
    Show / Hide Table of Contents

    Class ServiceProvider

    The default IServiceProvider.

    Inheritance
    Object
    ServiceProvider
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: Unity.AppUI.MVVM
    Syntax
    public sealed class ServiceProvider : IServiceProvider, IDisposable

    Constructors

    ServiceProvider(IServiceCollection)

    Create a new ServiceProvider.

    Declaration
    public ServiceProvider(IServiceCollection serviceCollection)
    Parameters
    Type Name Description
    IServiceCollection serviceCollection

    The service collection to use.

    Methods

    Dispose()

    Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

    Declaration
    public void Dispose()
    Implements
    IDisposable.Dispose()

    GetService(Type)

    Get a service from the service provider.

    Declaration
    public object GetService(Type serviceType)
    Parameters
    Type Name Description
    Type serviceType

    The type of the service to get.

    Returns
    Type Description
    Object

    The service instance.

    Implements
    IServiceProvider.GetService(Type)
    Exceptions
    Type Condition
    InvalidOperationException

    Thrown when the requested service is not registered.

    Extension Methods

    ServiceProviderExtensions.GetService<T>(IServiceProvider)
    ServiceProviderExtensions.GetRequiredService<T>(IServiceProvider)
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023