What is the difference between IWindsorContainer vs IUnityContainer?

I've worked with both 2 types of container between IWindsorContainer and IUnityContainer in different project for service and Interface binding. However I am not pretty sure what are the differences? Do they have same features? If yes then what is the need to develop another one on in case of existing one. Or do they have some differences? If yes, what is it? which purpose I am gonna use over which one? I have got a small documentation against this confusion, but I didn't quiet catch it. So if you let me know it then I will be grateful. Mention that, I am using NHibernet mapping here.


I have used both containers and the huge difference between them, over the years of using each has been that UnityContainer is managed by a team and is still being extended. The Windsor container was not very great at returning real errors. UnityContainer has great documentation and is very simple to install using nuget or some other repository manager.

Here is what I mean... if you look at how to use their code,https://github.com/castleproject/Windsor/blob/master/docs/README.md, windsor for example is very obfuscated.

public void Install(IWindsorContainer container, IConfigurationStore store)
    {
        container.Register(Classes.FromThisAssembly()
                            .Where(Component.IsInSameNamespaceAs<King>())
                            .WithService.DefaultInterfaces()
                            .LifestyleTransient());
    }

If you would look at unity, https://github.com/unitycontainer/unity/blob/master/quickstarts/CS/EventBroker/Src/Stoplight/Program.cs, it becomes more clear what is happening by registering them in a different way. The error codes when you are down the rabbit hole are also much more clean with Unity.

IUnityContainer container = new UnityContainer()

            .AddNewExtension<SimpleEventBrokerExtension>()

            .RegisterType<ILogger, TraceLogger>()

            .RegisterType<IStoplightTimer, RealTimeTimer>();

check out the following link. This might help you https://visualstudiomagazine.com/articles/2014/09/25/refactor-5.aspx

链接地址: http://www.djcxy.com/p/95268.html

上一篇: Swagger:通配符路径参数

下一篇: IWindsorContainer和IUnityContainer有什么区别?