Search Results for

    Show / Hide Table of Contents

    Class DependencyContainer

    A dependency injection container

    Inheritance
    System.Object
    DependencyContainer
    Namespace: OpenAPI.Plugins
    Assembly: OpenAPI.dll
    Syntax
    public class DependencyContainer : object

    Constructors

    | Improve this Doc View Source

    DependencyContainer()

    Declaration
    public DependencyContainer()

    Methods

    | Improve this Doc View Source

    CreateInstanceOf(Type)

    Use the DependencyContainer to create an instance for any type with a public constructor.

    Declaration
    public object CreateInstanceOf(Type type)
    Parameters
    Type Name Description
    Type type

    The type of the instance to create

    Returns
    Type Description
    System.Object

    An instance of type

    | Improve this Doc View Source

    CreateInstanceOf<TType>()

    Use the DependencyContainer to create an instance for any type with a public constructor.

    Declaration
    public TType CreateInstanceOf<TType>()
    Returns
    Type Description
    TType
    Type Parameters
    Name Description
    TType
    | Improve this Doc View Source

    Register<TType>(DependencyLifetime)

    Registers a new service

    Declaration
    public void Register<TType>(DependencyLifetime lifetime = DependencyLifetime.Singleton)
    Parameters
    Type Name Description
    DependencyLifetime lifetime

    How long to keep the service alive for

    Type Parameters
    Name Description
    TType

    The type of service to register

    Exceptions
    Type Condition
    DuplicateTypeException

    Thrown when a service of the same type has already been registered

    | Improve this Doc View Source

    RegisterSingleton(Type, Object)

    Registers a new singleton service

    Declaration
    public void RegisterSingleton(Type type, object value)
    Parameters
    Type Name Description
    Type type
    System.Object value
    | Improve this Doc View Source

    RegisterSingleton<TType>(TType)

    Registers a new singleton service

    Declaration
    public void RegisterSingleton<TType>(TType value)
    Parameters
    Type Name Description
    TType value

    The instance to use for dependency injection

    Type Parameters
    Name Description
    TType

    The type of service to register

    Exceptions
    Type Condition
    DuplicateTypeException

    Thrown when a service of the same type has already been registered

    | Improve this Doc View Source

    Remove(Type)

    Remove a service from dependency injection

    Declaration
    public void Remove(Type type)
    Parameters
    Type Name Description
    Type type
    | Improve this Doc View Source

    Remove<TType>()

    Remove a service from dependency injection

    Declaration
    public void Remove<TType>()
    Type Parameters
    Name Description
    TType
    | Improve this Doc View Source

    Resolve(Type)

    Resolve a service

    Declaration
    public object Resolve(Type type)
    Parameters
    Type Name Description
    Type type
    Returns
    Type Description
    System.Object

    The resolved service

    | Improve this Doc View Source

    Resolve<TType>()

    Resolve a service

    Declaration
    public TType Resolve<TType>()
    Returns
    Type Description
    TType

    The resolved service

    Type Parameters
    Name Description
    TType

    The type to resolve.

    | Improve this Doc View Source

    TryResolve(Type, out Object)

    Tries to resolve a service

    Declaration
    public bool TryResolve(Type type, out object dependency)
    Parameters
    Type Name Description
    Type type

    The type of service to resolve

    System.Object dependency

    The resolved service.

    Returns
    Type Description
    System.Boolean

    Whether the service was able to be resolved or not

    | Improve this Doc View Source

    TryResolve<TType>(out TType)

    Tries to resolve a service

    Declaration
    public bool TryResolve<TType>(out TType dependency)
    Parameters
    Type Name Description
    TType dependency

    The resolved service.

    Returns
    Type Description
    System.Boolean

    Whether the service was able to be resolved or not

    Type Parameters
    Name Description
    TType

    The type of service to resolve

    • Improve this Doc
    • View Source
    In This Article
    Back to top Generated by DocFX