An IOC Foundation (.net) for Beginners?

I just started learning Unity yesterday, abandoned this b / c due to lack of examples. I moved to Windsor Castle because they seemed to have a lot of documentation / activity. however, I got to their textbook, which they do not explain. For me, this means that they suggested that I have this knowledge. Not only that, but their downloadable sample project is not compatible with VS2010 - I had to crack the .csproj file to make it work.

I have seen many articles about .net IOC containers, but my question is "what is better for a beginner?". I want to find out, but I find it difficult when a thorough tutorial does not seem to exist.

To throw away another disappointing aspect, I only worked with vb.net, and all the examples there use C #. I know that they are basically the same languages, but you still need to continue to use the code converter, and then gather information when it does not work. I cannot use C # b / c employees who may change the code in the future.

Edit: I would define β€œeasy to learn,” as in the order of preference: tutorial / documentation / mailing list or forum

+4
source share
4 answers

It seems that this question always arises ... his question of preference, unity is fast, dirty, but the documentation is thin. But then again, most of the MS documentation is thin.

I have used Unity in the past, and it pretty much did everything I needed.

If you are looking for alternatives, Scott Hanselman has a blog that goes through them.

+1
source

This can help if you explain what your problem is; it’s easier for the community to solve specific problems than to answer β€œis there a simpler solution that does not require me to understand what I’m not formulating.” However, it would be nice to make sure you are happy with Fowler's articles on this subject ( http://martinfowler.com/articles/injection.html and http://martinfowler.com/bliki/InversionOfControl.html ). If you understand these articles, you can better ask questions specific to your problem domain.

To answer your question directly, I found that Ninject is the most intuitive dependency injection platform, mainly due to the pretty nice free interface for binding. StructureMap was almost as enjoyable. I have limited experience with Castle Windsor, usually only occasional use in other projects. I was working on a SharpArchitecture project project and replaced Windsor Ninject with previous projects.

Regarding the use of the DI library, the most important thing in my experience is to limit the control range of your DI card to a relatively small size. For example, I found that in web applications, DI containers are usually best when you only call them ControllerFactory.

The most tedious DI container I worked with was in Spring (although I'm sure it is better than when I last used it), but there are some really great examples of how to use it, since it has been as powerful as in the Java community and in .NET.

Edit: Assuming your goal is to learn how DI can be applied in a not completely trivial model project, consider the example project that comes with SharpArchitecture (perhaps after reading the tutorial on the SharpArchitecture website). See http://www.sharparchitecture.net/

The sample project is in C #, and the SharpArchitecture toolkit covers much more than dependency injections, but this should make you much more than most of the trivial examples of projects I've seen on the Internet.

+1
source

I think you need to first look into the concept of DI and what it gives you. Once you realize that learning different implementations is a lot easier.

So, my answer to your question is: β€œYour own,” which is the simplest basis for learning.

Learn the basics of DI and then create your own simple container and it will become more understandable IMO. You can create your own DI infrastructure in an hour or two.

James Kovacs has a great introduction to DI http://msdn.microsoft.com/en-ca/magazine/cc337885.aspx

Martin Fowler has two great articles explaining the concepts of http://martinfowler.com/bliki/InversionOfControl.html

http://martinfowler.com/articles/injection.html

0
source

I used Unity, which is owned by Microsoft and part of the Enterprise Library. It provides mapping based on configuration and code.

There is a good introduction:

http://msdn.microsoft.com/en-us/library/ff650320.aspx

-1
source

Source: https://habr.com/ru/post/1341350/


All Articles