title: Simple Injector: Cyclic Graph Error
body: <p>Registry:</p>
  
  <pre><code>container.Register&lt;IAuthenticationHandler, AuthenticationHandler&gt;(Lifestyle.Transient);
  container.Register&lt;IUserHandler, UserHandler&gt;(Lifestyle.Transient);    
  </code></pre>
  
  <p>Class 1:</p>
  
  <pre><code>public UserHandler(IAuthenticationHandler authenticationHandler)
  {
      _authenticationHandler = authenticationHandler;
  } 
  </code></pre>
  
  <hr>
  
  <p>Class 2:</p>
  
  <pre><code>public AuthenticationHandler(IUserHandler userHandler)
  {
      _userHandler = userHandler;
  }
  </code></pre>
  
  <hr>
  
  <p>I understand what the cyclic issue is. When the UserHandler is initialized, it is injecting the AuthenticationHandler implementation and then that is trying to create the UserHandler instance and the cycle begins...</p>
  
  <p>My question is how do I solve this in (SIMPLE INJECTOR) this situation and others where I need to inject like this?</p>
  
  <p>Thank you!</p>
  
  <p>UPDATE: </p>
  
  <pre><code>function AddUser(User user){ // User Handler
      _authenticationHandler.GenerateRandomSalt();
      string hashedPassword = _authenticationHandler.HashPassword(user.Password.HashedPassword, salt);
  }
  
  function Authenticate(string username, string password){ // Authentication Handler
      _userHandler.GetUserByUsername(username?.Trim());
  }
  </code></pre>
  
  <p>Bascially I need to call the UserHandler in the AuthenticationHandler to get the user and verify there is a user.</p>
  
  <p>I need to call the AuthenticationHandler in the UserHandler to get functions to salt and hash the password.</p>
  
  <p>I guess I could call the Repository to get the user but shouldn't I go through the service handler in case more stuff is done in the user service</p>