docs.unity3d.com
    Show / Hide Table of Contents

    Class ServiceProviderExtensions

    Extension methods for IServiceProvider.

    Inheritance
    Object
    ServiceProviderExtensions
    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 static class ServiceProviderExtensions

    Methods

    GetRequiredService<T>(IServiceProvider)

    Gets a service from the service provider. Throws an exception if the service is not found.

    Declaration
    public static T GetRequiredService<T>(this IServiceProvider serviceProvider)
        where T : class
    Parameters
    Type Name Description
    IServiceProvider serviceProvider

    The service provider.

    Returns
    Type Description
    T

    The service.

    Type Parameters
    Name Description
    T

    The type of the service.

    Exceptions
    Type Condition
    ArgumentNullException

    Thrown when serviceProvider is null.

    GetService<T>(IServiceProvider)

    Gets a service from the service provider.

    Declaration
    public static T GetService<T>(this IServiceProvider serviceProvider)
        where T : class
    Parameters
    Type Name Description
    IServiceProvider serviceProvider

    The service provider.

    Returns
    Type Description
    T

    The service.

    Type Parameters
    Name Description
    T

    The type of the service.

    Exceptions
    Type Condition
    ArgumentNullException

    Thrown when serviceProvider is null.

    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