How Dependency Injection Works in

  Рет қаралды 55,347

Raw Coding

Raw Coding

Күн бұрын

Пікірлер: 147
@kentswan3230
@kentswan3230 11 ай бұрын
Even though this is 3 years old the knowledge being explained is as current as yesterday. I'm going to need to watch this whole thing a couple of times because there's a ton of useful intrinsic understanding being rapidly but coherently presented that makes the other DI frameworks more understandable. A Belated THANKS!
@ivanvincent7534
@ivanvincent7534 3 жыл бұрын
Really impressive. Congratulations on your skill set, this is the ultimate under the hood tutorial.
@RawCoding
@RawCoding 3 жыл бұрын
Cheers)
@jankohler7560
@jankohler7560 4 жыл бұрын
Great! This is what i was looking for. Now it gets so much clearer.
@RawCoding
@RawCoding 4 жыл бұрын
Glad I could help
@dendeline_who
@dendeline_who 4 жыл бұрын
Thank you so much! I'm not good at English, but thanks to easy interpretation, lots of people like me will be interested in your content.
@RawCoding
@RawCoding 4 жыл бұрын
Thank you :)
@nikolazagorac8634
@nikolazagorac8634 Жыл бұрын
This is the best explanation I have seen yet
@RawCoding
@RawCoding Жыл бұрын
Glad you say that!
@azeddine8539
@azeddine8539 4 жыл бұрын
Super, Thanks. I Will be very happy if you can explain how MVC DI works.
@RawCoding
@RawCoding 4 жыл бұрын
Alright :)
@phaswanamalatjie5790
@phaswanamalatjie5790 Жыл бұрын
I know this video is old but it was a nice refresher. I enjoyed it, thank you.
@littlemancrs
@littlemancrs 4 жыл бұрын
Awesome stuff! I've started out in the IT world, less than a year ago, with videos from KudVenKat, for real beginners. But yours, are on a whole different level. I apreciate them very much. Also, I never thought that twich is used for anything other than games. :D GG!
@RawCoding
@RawCoding 4 жыл бұрын
Eyyy thanks man, and yeah I stream working on personal projects, where I can answer questions and talk with viewers, come join i post updates on discord)
@coreyb1102
@coreyb1102 Жыл бұрын
A month into my c# and asp net and you have the best tutorials haha down.
@RawCoding
@RawCoding Жыл бұрын
Glad you enjoy them!
@adistutorials5399
@adistutorials5399 4 жыл бұрын
Thanks for this man. You create really good contents, channel like this should go big for real!
@RawCoding
@RawCoding 4 жыл бұрын
Thanks ma dud)
@Arviniiii
@Arviniiii 3 ай бұрын
Thank you Anton for this valuable course !
@aliahmadi3902
@aliahmadi3902 Жыл бұрын
Thank you, Anton, you really opened my eyes to this concept. I just used it without understanding it.
@hadibazmi6340
@hadibazmi6340 4 жыл бұрын
Great work as always, tnx a lot i literally watched more than 5 hour worth of time videos about DI so i can grasp the full picture your video connected all the dots that i had. i'm looking forward for your MVC content that you mentioned at the end of this video.
@RawCoding
@RawCoding 4 жыл бұрын
Glad I could help and I think that video will come in about a week or 2
@PrasadJachak
@PrasadJachak 4 жыл бұрын
Thank you for this Video.. Middleware looked complex for me before this video. Now I understood how to works...
@RawCoding
@RawCoding 4 жыл бұрын
Awesome!
@eclipsetutorialvideo
@eclipsetutorialvideo 9 ай бұрын
Impressive you did it without edit it seems :) You did Singleton and Transient, it would be good to know how Scoped is working as lifetime
@-xeL
@-xeL 3 жыл бұрын
love the deep dives, nice work!
@RawCoding
@RawCoding 3 жыл бұрын
Cheers
@9415745
@9415745 4 жыл бұрын
these C# videos are fantastic, thanks!!
@RawCoding
@RawCoding 4 жыл бұрын
Cheers :)
@krystian9924
@krystian9924 Жыл бұрын
This tutorials are the real deal truly..like your making tutorials and explaining things in a way I would explain them to someone if I knew these topics haha Your explonations truly give you insight into topics, not just another abstractions to get by I think that this is what happens when you are truly passionate or have read some masterpieces (SICP shhh) 😉
@RawCoding
@RawCoding Жыл бұрын
thank you for the kind words. I attest my knowledge to Clojure
@sitalsitoula6536
@sitalsitoula6536 2 жыл бұрын
I am trying to wrap my head around the GetService method. Please tell me if my summary is right. Resolves the service. Using recursion. We want to resolve the service until it has no parameters. It essentially uses recursion to create necessary services starting from the ones that don't require parameters and use that to create another service in the chain until required service is generated.
@RawCoding
@RawCoding 2 жыл бұрын
Yes
@septinary
@septinary 4 жыл бұрын
This video helped me a lot. Thank you.
@RawCoding
@RawCoding 4 жыл бұрын
Thank you for watching :)
@vladimirmelnikov849
@vladimirmelnikov849 2 жыл бұрын
Amazing, this is so clear now. Thank you!
@RawCoding
@RawCoding 2 жыл бұрын
Glad I could help
@Eamo-21
@Eamo-21 Жыл бұрын
This is very cool! Advanced stuff is difficult to find on KZbin
@im1in260m
@im1in260m 2 жыл бұрын
An example of applying this to WPF would be excellent.
@vasugupta1
@vasugupta1 3 жыл бұрын
Great work, cheers for the clean explanation
@RawCoding
@RawCoding 3 жыл бұрын
thank you for watching :)
@balramverma4873
@balramverma4873 4 жыл бұрын
This is insanely great stuff :D Thank you Anton .
@RawCoding
@RawCoding 4 жыл бұрын
Thanks for watching))
@mrreadit1767
@mrreadit1767 Жыл бұрын
Hi @Raw Coding, thanks for the video. 1. Could you please elaborate on the scenario when the constructors of the services require some kind of data (authentication, etc.). So how would the static class Activator handle that while resolving? How is that handled in real world applications? 2. A mention about other types of DI would have been helpful (not just using constructors) - Being a bit exhaustive about the possibilities/ variants.
@mrreadit1767
@mrreadit1767 Жыл бұрын
1. Just had a look at the MVC video in one of your playlists. I think the reflected data can be parsed after a check (binding?) (using System.Type class)
@RawCoding
@RawCoding Жыл бұрын
If the service requires authentication, that service would have the httpcontext injected in to it, or some kind other service that loads authentication from the httpcontext and persists it through the scope. On point 2 - you can use reflection to assign things to fields or properties or in to functions.
@achilleskocaeli
@achilleskocaeli 4 жыл бұрын
Thanks Anton. You are my new hero..
@RawCoding
@RawCoding 4 жыл бұрын
Noooo, thank you for watching!
@ksichtmen
@ksichtmen 4 жыл бұрын
Awesome video! I would love to see the MVC explanation video. Maybe its already out (gonna check now) ~
@RawCoding
@RawCoding 4 жыл бұрын
It is check the playlist:)
@jxxqll
@jxxqll 4 жыл бұрын
Learned a lot! Thank you so much!
@RawCoding
@RawCoding 4 жыл бұрын
Thank you for watching )
@yazanshakhshir3049
@yazanshakhshir3049 2 жыл бұрын
You are a great person Thank you for the great explanation
@RawCoding
@RawCoding 2 жыл бұрын
Ty for watching)
@hirenpatel2006
@hirenpatel2006 4 жыл бұрын
Great video and very easy to follow
@RawCoding
@RawCoding 4 жыл бұрын
Cheers
@RamcoBros
@RamcoBros Жыл бұрын
Amazing Video, Nice explanation bro. Thank you for making the concepts clear. I This contents helps for the people who are new and starting to learn the programming and concepts associated with it.
@aslam5915
@aslam5915 3 жыл бұрын
Great!Thanks a lot, I really needed this video. Could you plz make a video with recursion?
@RawCoding
@RawCoding 3 жыл бұрын
Cheers, what question do you have about recursion?
@needpiebad
@needpiebad 4 жыл бұрын
Thanks for the video really helpful. Hey, just wondering if it'd make any sense to do this for MVVM in terms of injecting the services into view models. I get that there's MVVM frameworks out there that handle this sort of things just wondering if this is roughly the way they'd handle it?
@RawCoding
@RawCoding 4 жыл бұрын
Cheers, MVVM is MVC but you have the additional VM (view model) basically mapping between your data and what you want to display. There should be no need to do dependency injection when you do the mapping. View Model is a dumb object, just data representation, same as the Model. Only the controller has functions and has services injected to do stuff to the models.
@The69pawlak
@The69pawlak 4 жыл бұрын
Very useful stuff, thanks for that!
@RawCoding
@RawCoding 4 жыл бұрын
Thank you for watching!
@fletcherdukakis934
@fletcherdukakis934 4 жыл бұрын
First off, awesome video! Couple questions. Can you briefly describe (or point me to some resources) describing why we needed to pass the Activator.CreateInstance as a delegate to the CreateImplementation method. Also, I understand that this isn’t production ready code, but with the Transient dependencies, wouldn’t the reference to the instance exist for the lifetime of the container. If an application creates multiple instances, they’d never actually get released /garbage collected. Am I understanding that correctly?
@RawCoding
@RawCoding 4 жыл бұрын
So I’ve just used an abstract factory pattern there without an interface and the factory is just a function (well in c# delegates are object but anyway) you want to look for abstract factory pattern. As I understand it the application has 1 DI container so as soon as the service that consumes a transient service is disposed of the transient service is disposed as well. Otherwise we would run out of memory eventually.
@wisnu7734
@wisnu7734 4 жыл бұрын
i love your all videos....just to advice for you..please add graphics or animation while you explain something such analogy....
@RawCoding
@RawCoding 4 жыл бұрын
Good idea!
@alexspeleers
@alexspeleers 4 жыл бұрын
Thnx for good explanation of creation of custom DI container. Can you use classic VS for coding - easier to migrate via code due to familiar interface?
@RawCoding
@RawCoding 4 жыл бұрын
Cheers, I think LinqPad is easier to explain things due to it’s visualisation features.
@lucianbumb6690
@lucianbumb6690 4 жыл бұрын
yes for MVC what is the performance impact of reflection?
@RawCoding
@RawCoding 4 жыл бұрын
Ehmmm, I can’t say, depends what parts of the api you are using
@sachinsaini8595
@sachinsaini8595 2 жыл бұрын
Nice video....very well explained...
@RawCoding
@RawCoding 2 жыл бұрын
Cheers
@pintileiciprian
@pintileiciprian 3 жыл бұрын
Yet another great video from Anton. Well done! P. S. What keyboard do you use? Sounds nice.
@RawCoding
@RawCoding 3 жыл бұрын
It’s filco convertible with mx brown switches
@emmepombar3328
@emmepombar3328 2 жыл бұрын
41:32 Awesome, but I see one flaw, if I am correct. If I try to create an implementation of an class Foo as singleton with a ctor Foo(Bar b), then every time, Bar b is resolved.
@RawCoding
@RawCoding 2 жыл бұрын
not sure what the flaw is?
@ArjunKRaj-vt4vw
@ArjunKRaj-vt4vw 3 жыл бұрын
Excellent video
@RawCoding
@RawCoding 3 жыл бұрын
Cheers
@TotoMacFrame
@TotoMacFrame Ай бұрын
Great stuff. But wouldn't this start to break as soon as a Service needs parameters of atomic data types like int or string, since they cannot really be instanciated with the correct values using this Activator logic? Like in a case of a Dependency of a FileLogger that needs a target file path...
@anatoliytkachenko7081
@anatoliytkachenko7081 3 жыл бұрын
Anton, thank you a lot for explanation! Like!
@RawCoding
@RawCoding 3 жыл бұрын
Thank you for watching!
@abuzeromohammed3386
@abuzeromohammed3386 4 жыл бұрын
Thank you for these special video s
@RawCoding
@RawCoding 4 жыл бұрын
Thank you for watching :)
@youngliao5772
@youngliao5772 4 жыл бұрын
Cool guy, really appreciate your tutorial video
@RawCoding
@RawCoding 4 жыл бұрын
Thank you))
@aloksaxena7905
@aloksaxena7905 4 жыл бұрын
It's good video, do not mind to say its very deep thought
@RawCoding
@RawCoding 4 жыл бұрын
cheers :)
@georgedraghiceanu1526
@georgedraghiceanu1526 3 жыл бұрын
Great video!
@RawCoding
@RawCoding 3 жыл бұрын
Cheers
@Shinee3e
@Shinee3e 4 жыл бұрын
Thanks dude very clean and straightforward (implemenentatation lol) i would like you to make MVC video for sure thanks again;
@RawCoding
@RawCoding 4 жыл бұрын
Thanks and actually did make it check the playlist:)
@Shinee3e
@Shinee3e 4 жыл бұрын
@@RawCoding Oh sorry didn't notice, will check it soon.
@olegchuryukin158
@olegchuryukin158 4 жыл бұрын
Thank you for excellent video
@RawCoding
@RawCoding 4 жыл бұрын
Thank you for watching
@ЕгорБрызгалов-я4я
@ЕгорБрызгалов-я4я 4 жыл бұрын
Thank you a lot!:)
@RawCoding
@RawCoding 4 жыл бұрын
Thanks for watching as always :)
@kannanp4811
@kannanp4811 3 жыл бұрын
Thank you so much
@RawCoding
@RawCoding 3 жыл бұрын
Thank you for watching )
@mohammadjouhari4607
@mohammadjouhari4607 10 ай бұрын
great stuffs. keeps going.
@parsalotfy
@parsalotfy 3 жыл бұрын
thank you for this video
@RawCoding
@RawCoding 3 жыл бұрын
Thank you for watching
@brahmcdude685
@brahmcdude685 3 жыл бұрын
why no interfaces? what is the use of a type without a base interface?
@RawCoding
@RawCoding 3 жыл бұрын
This is just an example
@nouchance
@nouchance 2 жыл бұрын
Thank you Sir!
@cdeba9867
@cdeba9867 3 жыл бұрын
when do u stream?
@RawCoding
@RawCoding 3 жыл бұрын
Wed & Sun on twitch, you can ask for stream squad role on discord to get notified
@abdelrhmanahmed1378
@abdelrhmanahmed1378 3 жыл бұрын
What if we want to inject interfaces and then resolve them to a concrete implementation
@RawCoding
@RawCoding 3 жыл бұрын
Just cast the object
@abdelrhmanahmed1378
@abdelrhmanahmed1378 3 жыл бұрын
Can you elaborate more please
@RawCoding
@RawCoding 3 жыл бұрын
var myImp = (Implementation) myInterface
@abdelrhmanahmed1378
@abdelrhmanahmed1378 3 жыл бұрын
Thanks for replying the problem is , when we register we register and interface , so when getservice the list in the container containes the interface , the predicate that evaluate abd return the dependency, the change need to be done there right ?
@RawCoding
@RawCoding 3 жыл бұрын
I don’t understand
@denisosipenko7413
@denisosipenko7413 4 жыл бұрын
Thanks a lot! You are realy cool! 👍👍👍👍👍
@RawCoding
@RawCoding 4 жыл бұрын
Cheers)
@thesuperiorman8342
@thesuperiorman8342 4 жыл бұрын
Very strange. I've never come across the method Dump()
@RawCoding
@RawCoding 4 жыл бұрын
It's only available in LINQPad
@algarud
@algarud 4 жыл бұрын
Man, you're so cool!
@RawCoding
@RawCoding 4 жыл бұрын
Cheers:)
@TheDogfighter13
@TheDogfighter13 7 ай бұрын
anybody knows how to add scoped to this , i tried but it's not working right
@rmcgraw7943
@rmcgraw7943 8 күн бұрын
Scoped is connection-centric, so in IIS that is Session-based. You would store the instance of a scoped instance in a Session variable, and access that instance as if it were a static variable. Likely, the reason he didnt put it here is because this would work for more than just web-based solutions, and scoped is a web-server based option for DI. Note: Transcient is on-request; Singleton is single-instance per process. Another option that could be, should be, created for a high volume enterprise would be Pooled (with the ability to specify the number of instance in the pool); Stephen Taub has a great video about ‘pools and pooling’.
@parsalotfy
@parsalotfy 3 жыл бұрын
very rich content
@RawCoding
@RawCoding 3 жыл бұрын
Cheers)
@ultramasculine
@ultramasculine 2 жыл бұрын
I love u dude
@RawCoding
@RawCoding 2 жыл бұрын
Ty dude )
@grafterallday3763
@grafterallday3763 3 жыл бұрын
Are you Scandinavian ?, I could be totally wrong but I'm sensing you are one.
@RawCoding
@RawCoding 3 жыл бұрын
I’m half Swedish )
@grafterallday3763
@grafterallday3763 3 жыл бұрын
@@RawCoding I knew it ! min bror !
@rmcgraw7943
@rmcgraw7943 8 күн бұрын
LOL, you removed my suggestions for improvements. I was going to suggest your courses to my team of junior devs, but now I think I shall provision that budget elsewhere.
@RawCoding
@RawCoding 8 күн бұрын
Mhm?
@kopilkaiser8991
@kopilkaiser8991 Жыл бұрын
I lost understanding from the part where you add the parameter in the container. I will repeat and again try to understand. This dependency injection is complicated or I think you have gone a bit complex on trying to build a generic application which will be compatible with any type. I will not give up to give effort to understand.
@RawCoding
@RawCoding Жыл бұрын
the container contains types that it knows how to create, if 1 type requires other types to be created, the container needs to know about those required types and how to inject them.
@cffee_
@cffee_ 3 жыл бұрын
Transient lifetime is an Anti Pattern, breaks single responsibility principle makes code behavior easier to break.
@RawCoding
@RawCoding 3 жыл бұрын
Exactly how?
@RayanMADAO
@RayanMADAO Жыл бұрын
So much abstraction it makes me confused
@hydtechietalks3607
@hydtechietalks3607 4 жыл бұрын
whats this secret talk... speak louder dear!
@RawCoding
@RawCoding 4 жыл бұрын
Haha that was back when I just got the mic, was trying to configure it
@eclipsetutorialvideo
@eclipsetutorialvideo 9 ай бұрын
Impressive you did it without edit it seems :) You did Singleton and Transient, it would be good to know how Scoped is working as lifetime
@aaaaasssss884
@aaaaasssss884 2 жыл бұрын
Good stuff!!
@RawCoding
@RawCoding 2 жыл бұрын
Cheers
C# Async/Await/Task Explained (Deep Dive)
24:22
Raw Coding
Рет қаралды 415 М.
小丑揭穿坏人的阴谋 #小丑 #天使 #shorts
00:35
好人小丑
Рет қаралды 54 МЛН
FOREVER BUNNY
00:14
Natan por Aí
Рет қаралды 12 МЛН
In/Out Middleware Explained (C# ASP.NET Core & JS Examples)
54:03
C#'s Best features you might not be using
31:20
dotnet
Рет қаралды 14 М.
Dependency Injection простыми словами
18:17
devschacht “Девшахта”
Рет қаралды 87 М.
Semaphore Explained C#
12:24
Raw Coding
Рет қаралды 41 М.
Dependency Injection in .NET Core (.NET 6)
1:00:32
IAmTimCorey
Рет қаралды 194 М.
Dependency Injection Is Now Complete In .NET 8!
9:49
Nick Chapsas
Рет қаралды 95 М.
Dependency Injection, The Best Pattern
13:16
CodeAesthetic
Рет қаралды 879 М.
C# Delegates & Lambdas Explained
32:43
Raw Coding
Рет қаралды 39 М.
Structuring Dependency Injection In ASP.NET Core The Right Way
16:22
Milan Jovanović
Рет қаралды 54 М.
小丑揭穿坏人的阴谋 #小丑 #天使 #shorts
00:35
好人小丑
Рет қаралды 54 МЛН