Skip to content

Commit

Permalink
Check if Dependency Resolver is configured to avoid a `NullReferenceE…
Browse files Browse the repository at this point in the history
…xception`
  • Loading branch information
augustoproiete committed Oct 16, 2018
1 parent e408e3d commit 9d2a26c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
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

0 comments on commit 9d2a26c

Please sign in to comment.