Skip to content

Instantly share code, notes, and snippets.

@Ibro
Created January 18, 2020 09:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ibro/cbdbf092343716ed73bf2dfc56e3cc29 to your computer and use it in GitHub Desktop.
Save Ibro/cbdbf092343716ed73bf2dfc56e3cc29 to your computer and use it in GitHub Desktop.
ASP.NET Core DI
public class MyConnectionManager : IMyConnectionManager
{
private readonly ILogger<MyConnectionManager> _logger;
private readonly IMyScopedService _myScopedService;
public MyConnectionManager(ILogger<MyConnectionManager> logger, IMyScopedService myScopedService)
{
_logger = logger;
_myScopedService = myScopedService;
}
public void DoSomething()
{
_logger.LogInformation( $"{nameof(MyConnectionManager)} does something");
_logger.LogInformation( $"Calling {nameof(MyScopedService)}.{nameof(MyScopedService.DoSomething)}");
_myScopedService.DoSomething();
}
}
public interface IMyConnectionManager
{
void DoSomething();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment