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;
using System;
namespace JrTech.AspNetCore.Web.Controllers
{
[Route("api/[controller]")]
public class ValuesController : Controller
{
private readonly Func<IRandomNumberGenerator> _numberGeneratorFactory;
public ValuesController(Func<IRandomNumberGenerator> numberGeneratorFactory)
{
_numberGeneratorFactory = numberGeneratorFactory;
}
// GET api/values
[HttpGet]
public string Get()
{
var generator = _numberGeneratorFactory();
return $"randomNumber - {generator.Get()}" ;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment