What Is Method Dependency Injection? #shorts

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

Just woke up. With coffee. Watched this 15 times before it finally sunk in. Awesome great tip!

BrendanAlexander
Автор

I used this. It is cool. But it feels strange to mix query parameters with DI. A little like black magic.

nothingisreal
Автор

Love it...I had to hack something similar a few years ago for an internal job scheduler, wanted to avoid boilerplate with constructor parameters dependencies when creating new jobs. Very interested in snooping the source code on how they do this. I love OSS

cheesypufs
Автор

It's even better to do method injection than class in some scenarious. Especially when you have controllers instead of minimal API and you have a lot of services injected into controller

winchester
Автор

Method Injection can be useful - recently I’ve used it to make testing possible in some part of codebase without huge refactor but for me it isn’t default choice

adrian_franczak
Автор

What do you think about using Discriminated Unions as return-type in MediatR Handler? ( for example OneOf )

hlickx
Автор

If I use ServiceCollection in my service layer, is it a bad approach? actually, I don't want to inject unnecessary DI for a method. such as I have a service contains 4 methods, and each method uses its own DI, so I need to inject all Dependencies in the contractor level, but I don't want that. I want to specific Dependency in a specific method, now I resolve this by using ServiceCollection. is there any better approach?

SrabanNadimulIslamBhuyan