Skip to content

Instantly share code, notes, and snippets.

@PoisonousJohn
Created February 21, 2018 09:28
Show Gist options
  • Save PoisonousJohn/43e5517e36f1da5ded945b8a4e2311d9 to your computer and use it in GitHub Desktop.
Save PoisonousJohn/43e5517e36f1da5ded945b8a4e2311d9 to your computer and use it in GitHub Desktop.
Incorrect dependency injection
public class APIService : IAPIService
{
private readonly Lazy<ILogger> _logger;
public APIService()
{
_logger = Services.log;
}
public string UserId { get; private set; }
public void Login()
{
_logger.Value.Log("Login started");
UserId = "registeredUser1";
_logger.Value.Log("Login ended");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment