Skip to content

Instantly share code, notes, and snippets.

@alimozdemir
Created May 30, 2020 13:59
Show Gist options
  • Save alimozdemir/1579a04b01cc03b2046ca8b4467bf5b4 to your computer and use it in GitHub Desktop.
Save alimozdemir/1579a04b01cc03b2046ca8b4467bf5b4 to your computer and use it in GitHub Desktop.
[ApiController]
[Route("[controller]")]
public class ServiceController : ControllerBase
{
private readonly ITransientService _transientService;
private readonly IScopedService _scopedService;
private readonly ISingletonService _singletonService;
public ServiceController(ITransientService transientService, IScopedService scopedService, ISingletonService singletonService)
{
_transientService = transientService;
_scopedService = scopedService;
_singletonService = singletonService;
}
[HttpGet("Transient")]
public string Transient()
{
return _transientService.GetValue();
}
[HttpGet("Scoped")]
public string Scoped()
{
return _scopedService.GetValue();
}
[HttpGet("Singleton")]
public string Singleton()
{
return _singletonService.GetValue();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment