What is the difference between Castle Windsor "Container" and "Core"?

I am starting to use Windsor, and I want to understand when to use container and kernel . For instance.

 var c = new WindsorContainer(); c.Register(Component.For<ITt>().ImplementedBy<Tt>()); var tt = c.Resolve<ITt>(); 

Everything is in order and everything works, but here is also c.kernel , which can do the same as for?

 var c = new WindsorConatiner(); c.kernel.Register(Component.For<ITt>().ImplementedBy<Tt>()); var tt = c.kernel.Resolve<ITt>(); 

Honestly, I don’t understand well if there is a difference between the "Strong> Container " and the " Core . In my head, does this sound like two names of the same thing in different IoC libraries?

PS I read this post , but still can’t understand why I need to leave two implementations of the same function here?

Update: I just found such a line in my code

  c.Kernel.Resolver.AddSubResolver(new ArrayResolver(c.Kernel)); 

What reason was to do this through Kernel? I completely lost

+5
source share
1 answer

Today they are basically equivalent, but first IKernel and IWindsorContainer live in separate assemblies, and the Windsor container wraps the core. Both were merged at some point, but were kept alive to provide backward compatibility for users who may have used one or the other.

Since the merger took place in version 2.5 (as discussed in the related post), it is reasonable to assume that there are some non-negligible numbers of users who may have worked on one interface or another, hence the cool one you see now.

Having looked at the code, you can see that almost all of the code from the Windsor container calls the inner core, with some behavior added for child containers functionality, another option that r is extracted from the past and is not necessarily useful

Those who, although Im seriously going to remove support for nested containers will be sure that this will not happen. I still think this might be a viable option, and I wanted to throw it in the air, but it became such a core feature of every IoC container that the Windsor would look crippled if it didn't have it, whether or not it really necessary.

In the end, I would recommend using a container; it wraps the kernel and is the official entry point for managing your application (for example, the Install method does not exist on the kernel)

+13
source

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


All Articles