How many assemblies is Unity?

Apr 29, 2008 at 9:50 AM
I'm looking to include an IOC container in a new project. Unity is definitely a consideration (hey!, it's MS), but I'm wondering how many assemblies I have to reference in my projects.

Also, will Unity do automatic injection, or do I have to decorate all my injected classes with attributes?
I find this attribute decoration annoying for older components in other projects.

Apr 29, 2008 at 12:46 PM
You do not have to, you could do this using the config. Check this link:

Apr 29, 2008 at 9:10 PM
Unity ships with four assemblies.

Two of them, Microsoft.Practices.ObjectBuilder2 and Microsoft.Practices.Unity, are required.

Microsoft.Practices.Unity.Configuration is only needed if you are configuring your containers via web/app.config files.

Microsoft.Practices.Unity.StaticFactory is a completely optional component that allows you to specify a delegate to create your objects.

Unity will do automatic constructor injection. If you want properties or methods to be injected, you have three choices:

1) Attributes on the class.
2) Configure the container to inject properties & methods via an API call on the container.
3) Configure the container via a config file.

All these options are covered in the documentation, and there are lots of examples on the forums.

(My personal favorite these days is #2, but that's just me).

Take a look at the docs, play with it, and if you have any questions feel free to ask.
Apr 29, 2008 at 10:54 PM
Could you give an example on #2, are you talking about InjectionMethod?
Apr 30, 2008 at 12:31 AM
I'm talking about stuff like this:

            new InjectionProperty("Bar"),
            new InjectionProperty("Baz", 42));

There are lots of examples here in the forums, in samples around the web, and in our documentation.