Search Results for

    Show / Hide Table of Contents

    Class DependencyResolver

    Provides users with immediate access to the IDependencyResolver bound to this ActorSystem, if any.

    Inheritance
    object
    DependencyResolver
    Implements
    IExtension
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Akka.DependencyInjection
    Assembly: Akka.DependencyInjection.dll
    Syntax
    public sealed class DependencyResolver : IExtension

    Constructors

    | Edit this page View Source

    DependencyResolver(IDependencyResolver)

    Declaration
    public DependencyResolver(IDependencyResolver resolver)
    Parameters
    Type Name Description
    IDependencyResolver resolver

    Properties

    | Edit this page View Source

    Resolver

    The globally scoped IDependencyResolver.

    Declaration
    public IDependencyResolver Resolver { get; }
    Property Value
    Type Description
    IDependencyResolver
    Remarks

    Per https://docs.microsoft.com/en-us/dotnet/core/extensions/dependency-injection-guidelines - please use the appropriate IServiceScope for your actors and the dependencies they consume. DI is typically not used for long-lived, stateful objects such as actors.

    Therefore, injecting transient dependencies via constructors is a bad idea in most cases. You'd be far better off creating a local "request scope" each time your actor processes a message that depends on a transient dependency, such as a database connection, and disposing that scope once the operation is complete.

    Actors are not MVC Controllers. Actors can live forever, have the ability to restart, and are often stateful. Be mindful of this as you use this feature or bad things will happen. Akka.NET does not magically manage scopes for you.

    Methods

    | Edit this page View Source

    For(ActorSystem)

    Declaration
    public static DependencyResolver For(ActorSystem actorSystem)
    Parameters
    Type Name Description
    ActorSystem actorSystem
    Returns
    Type Description
    DependencyResolver
    | Edit this page View Source

    Props(Type)

    Used to dynamically instantiate an actor where some of the constructor arguments are populated via dependency injection and others are not.

    Declaration
    public Props Props(Type type)
    Parameters
    Type Name Description
    Type type

    The type of actor to instantiate.

    Returns
    Type Description
    Props

    A new Props instance which uses DI internally.

    Remarks

    YOU ARE RESPONSIBLE FOR MANAGING THE LIFECYCLE OF YOUR OWN DEPENDENCIES. AKKA.NET WILL NOT ATTEMPT TO DO IT FOR YOU.

    | Edit this page View Source

    Props(Type, params object[])

    Used to dynamically instantiate an actor where some of the constructor arguments are populated via dependency injection and others are not.

    Declaration
    public Props Props(Type type, params object[] args)
    Parameters
    Type Name Description
    Type type

    The type of actor to instantiate.

    object[] args

    Optional. Any constructor arguments that will be passed into the actor's constructor directly without being resolved by DI first.

    Returns
    Type Description
    Props

    A new Props instance which uses DI internally.

    Remarks

    YOU ARE RESPONSIBLE FOR MANAGING THE LIFECYCLE OF YOUR OWN DEPENDENCIES. AKKA.NET WILL NOT ATTEMPT TO DO IT FOR YOU.

    | Edit this page View Source

    Props<T>()

    Used to dynamically instantiate an actor where some of the constructor arguments are populated via dependency injection and others are not.

    Declaration
    public Props Props<T>() where T : ActorBase
    Returns
    Type Description
    Props

    A new Props instance which uses DI internally.

    Type Parameters
    Name Description
    T

    The type of actor to instantiate.

    Remarks

    YOU ARE RESPONSIBLE FOR MANAGING THE LIFECYCLE OF YOUR OWN DEPENDENCIES. AKKA.NET WILL NOT ATTEMPT TO DO IT FOR YOU.

    | Edit this page View Source

    Props<T>(params object[])

    Uses a delegate to dynamically instantiate an actor where some of the constructor arguments are populated via dependency injection and others are not.

    Declaration
    public Props Props<T>(params object[] args) where T : ActorBase
    Parameters
    Type Name Description
    object[] args

    Optional. Any constructor arguments that will be passed into the actor's constructor directly without being resolved by DI first.

    Returns
    Type Description
    Props

    A new Props instance which uses DI internally.

    Type Parameters
    Name Description
    T

    The type of actor to instantiate.

    Remarks

    YOU ARE RESPONSIBLE FOR MANAGING THE LIFECYCLE OF YOUR OWN DEPENDENCIES. AKKA.NET WILL NOT ATTEMPT TO DO IT FOR YOU.

    Implements

    IExtension

    Extension Methods

    ObjectExtensions.IsDefaultForType<T>(T)
    ObjectExtensions.AsOption<T>(T)
    Extensions.AsInstanceOf<T>(object)
    In this article
    • githubEdit this page
    • View Source
    Back to top
    Contribute
    • Project Chat
    • Discussion Forum
    • Source Code
    Support
    • Akka.NET Support Plans
    • Akka.NET Observability Tools
    • Akka.NET Training & Consulting
    Maintained By
    • Petabridge - The Akka.NET Company
    • Learn Akka.NET