I’ve been working with Microsoft’s Unity IOC container. There are a bunch of overloads for the RegisterType() method all looking similar to
IUnityContainer RegisterType(Type t, params InjectionMember[] injectionMembers);
I’m wondering when the injectionMembers parameters are for? I couldn’t find any documentation for the them (even though they’re in every overload) and none of the sample code I looked at use them.
Am I missing something here? Are they not commonly used or did I just miss the examples?
The overload with the
InjectionMemberarray is used, when you do not provide a configuration file that Unity tells how to create an instance of the given type or if you want to create an instance by another way than defined in the configuration file.The overloads are used, when you want to configure an unity container without a configuration file. An
InjectionMembercan be a constructor, property or method call.The following code, taken from the Unity help, shows how to use
InjectionMembersthrough the fluent interface of the container.The following XML configuration is equivalent to the code above.