C# - Create an IoC Container from Scratch

preview_player
Показать описание
In this tutorial we’ll build a IoC container from scratch which supports transient and singleton registries. The code we write is fully unit tested with NUnit and I think you’ll learn some valuable tips.

If you have any questions please leave them in the comment section below. Thanks for watching!

You can find the source code on my GitHub.
Рекомендации по теме
Комментарии
Автор

Little late, but here are some things to consider:
- you can use the Invoke - method on the constructor directly, no need for Activator. Invoke also takes an object[]
- consider using a generic type constraint in your Register - method. Something like: where TOut :TIn
- instead of calling ContainsKey on a dictionary and then retrieving the object with the indexer, consider using TryGetValue. This spends less time in the dictionary and thus is expected to be faster

Offseasoncornbread
Автор

I just rewatched this for the first time in a while and it's great

WesDoyle
Автор

Thanks for the video. Surprisingly it has almost 1 to 1 correspondence to PHP implementation in terms of syntax.

sanzhar.danybayev
Автор

If anyone is having trouble with the "Should()" in subject.Should().BeOfType(A) is not recognized, add the NuGet package "Fluent Assertions"

danbarry
Автор

Hello Baylor, Nice Video keep it up!, I am just curious to know which IDE or Editor you used???, is it visual studio??

ankitpodal
Автор

That's great. I love it. Thanks a lot for sharing :-)

karthiksanjay
Автор

Thank you! I wanted to build a IoC for a personal project (I could use a premade one but where is the fun in that) and this is a great tutorial (not just in how to make a IoC but also in TDD). If the singleton is really driving you made you could have a guid in the test class and check that. Thanks for the video :)

maxclifford
Автор

I really like this tutorial. Thank you!

brtk
Автор

Awesome video. How long have you been programming in C#?

Eclipse
Автор

Very good tut. But I dont agree with the Singleton part, I believe that lets say you create multiple different pets, lets say pet1, pet2, pet3. they all should be of the exactly same type.. and not of type object, yeah I understand its a workaround, but still.... really good tutorial nevertheless

eldinphp
Автор

good for the contents but it makes me feel sick in the stomach to watch your typing.
Just could not view it passed @25:10

jacquesdemolay