Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if Dependency Resolver is configured to avoid a NullReferenceException #3619

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,15 @@ public class DIActorContextAdapter
/// <exception cref="ArgumentNullException">
/// This exception is thrown when the specified <paramref name="context"/> is undefined.
/// </exception>
/// <exception cref="InvalidOperationException">
/// This exception is thrown when the Dependency Resolver has not been configured in the <see cref="ActorSystem" />.
/// </exception>
public DIActorContextAdapter(IActorContext context)
{
if (context == null) throw new ArgumentNullException(nameof(context), $"DIActorContextAdapter requires {nameof(context)} to be provided");
this.context = context;
this.producer = context.System.GetExtension<DIExt>();
if (producer == null) throw new InvalidOperationException("The Dependency Resolver has not been configured yet");
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,15 @@ public class DIActorSystemAdapter
/// <exception cref="ArgumentNullException">
/// This exception is thrown when the specified <paramref name="system"/> is undefined.
/// </exception>
/// <exception cref="InvalidOperationException">
/// This exception is thrown when the Dependency Resolver has not been configured in the <see cref="ActorSystem" />.
/// </exception>
public DIActorSystemAdapter(ActorSystem system)
{
if (system == null) throw new ArgumentNullException(nameof(system), $"DIActorSystemAdapter requires {nameof(system)} to be provided");
this.system = system;
this.producer = system.GetExtension<DIExt>();
if (producer == null) throw new InvalidOperationException("The Dependency Resolver has not been configured yet");
}

/// <summary>
Expand Down