Search Results for

    Show / Hide Table of Contents

    Class ActivatorUtilities

    Helper code for the various activator services.

    Inheritance
    object
    ActivatorUtilities
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: nanoFramework.DependencyInjection
    Assembly: nanoFramework.DependencyInjection.dll
    Syntax
    public static class ActivatorUtilities

    Methods

    CreateInstance(IServiceProvider, Type, params object[])

    Instantiate a type with constructor arguments provided directly and/or from an IServiceProvider.

    Declaration
    public static object CreateInstance(IServiceProvider provider, Type instanceType, params object[] parameters)
    Parameters
    Type Name Description
    IServiceProvider provider

    The service provider used to resolve dependencies.

    Type instanceType

    The type to activate.

    object[] parameters

    Constructor arguments not provided by the provider.

    Returns
    Type Description
    object

    An activated object of type instanceType.

    Exceptions
    Type Condition
    InvalidOperationException

    A suitable constructor for type instanceType could not be located. Ensure the type is concrete and all parameters of a public constructor are either registered as services or passed as arguments. Also ensure no extraneous arguments are provided.

    GetServiceOrCreateInstance(IServiceProvider, Type, params object[])

    Retrieve an instance of the given type from the service provider. If one is not found then instantiate it directly.

    Declaration
    public static object GetServiceOrCreateInstance(IServiceProvider provider, Type type, params object[] parameters)
    Parameters
    Type Name Description
    IServiceProvider provider

    The service provider.

    Type type

    The type of the service.

    object[] parameters

    Constructor arguments not provided by the provider.

    Returns
    Type Description
    object

    The resolved service or created instance.

    Exceptions
    Type Condition
    InvalidOperationException

    Unable to resolve a service while attempting to activate a constructor.

    In this article
    Back to top Copyright © 2023 nanoFramework Contributors
    Generated by DocFX