Skip to content

Instantly share code, notes, and snippets.

@darrencauthon
Created September 3, 2014 02:38
Show Gist options
  • Save darrencauthon/9a02cca19aeeeb548555 to your computer and use it in GitHub Desktop.
Save darrencauthon/9a02cca19aeeeb548555 to your computer and use it in GitHub Desktop.
DI Sample
class ProductController < ApplicationController
def index
@products = Product.all
end
end
public class ProductController : Controller
{
private IProductRepository _productRepository;
public ProductController(IProductRepository productRepository)
{
_productRepository = productRepository;
}
public ActionResult Index()
{
products = productRepository.getAll();
return View(products);
}
}
@RonJeffries
Copy link

This may be a perfectly good way to code it, and to test it. It's simple, I like it, and it'll probably do just fine. IMO, however, it is not Dependency Injection, simply because there is no injection going on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment