Skip to content

Instantly share code, notes, and snippets.

@jrob5756
Created Sep 29, 2018
Embed
What would you like to do?
using Microsoft.AspNetCore.Mvc;
namespace JrTech.AspNetCore.Web.Controllers
{
[Route("api/[controller]")]
public class ValuesController : Controller
{
private readonly IFactory<IRandomNumberGenerator> _numberGeneratorFactory;
public ValuesController(IFactory<IRandomNumberGenerator> numberGeneratorFactory)
{
_numberGeneratorFactory = numberGeneratorFactory;
}
// GET api/values
[HttpGet]
public string Get()
{
var generator = _numberGeneratorFactory.Create();
return $"randomNumber - {generator.Get()}" ;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment