docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class ServiceProvider

    The default IServiceProvider.

    Inheritance
    object
    ServiceProvider
    Implements
    IServiceProvider
    IDisposable
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Unity.AppUI.MVVM
    Assembly: Unity.AppUI.MVVM.dll
    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.

    Exceptions
    Type Condition
    ArgumentNullException

    Thrown when the service collection is null.

    Methods

    CreateScope()

    Create a new scope.

    Declaration
    public IServiceScope CreateScope()
    Returns
    Type Description
    IServiceScope

    The new scope.

    Dispose()

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

    Declaration
    public void 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.

    Exceptions
    Type Condition
    InvalidOperationException

    Thrown when the requested service is not registered.

    Implements

    IServiceProvider
    IDisposable

    Extension Methods

    ServiceProviderExtensions.GetRequiredService<T>(IServiceProvider)
    ServiceProviderExtensions.GetRequiredService<T>(IServiceProvider)
    ServiceProviderExtensions.GetService<T>(IServiceProvider)
    ServiceProviderExtensions.GetService<T>(IServiceProvider)
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)