Skip to content

Using dependency injection which as great Scott says: "is available in a consistent way throughout the entire web stack" #408

Closed
@developer1998

Description

@developer1998

So I enable it inside Startup.cs as so:

services.AddSingleton < IClientPackagesRepository, ClientPackagesRepository > () ;

I can do the injection on Controller level using

private readonly IClientPackagesRepository _repository;
public HomeController(IClientPackagesRepository repository)

I can do the injection as well on View level using

@inject IClientPackagesRepository repository;

What about if I want to do the injection right in Startup.cs?
I cannot figure out how to do it, and according to great Scott says in
https://weblogs.asp.net/scottgu/introducing-asp-net-5
I should be able.
I am thinking along the lines

app.UseServices...

Thanks for your help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions