1

In Unity 3, We have the following constructor for InjectionFactory

public InjectionFactory(Func<IUnityContainer, Type, string, object> factoryFunc)

Can someone tell me what is the meaning of the last three parameters Type, string, object ?

alcoforado
  • 516
  • 1
  • 4
  • 17

1 Answers1

1

The InjectionFactory itself only expects a delegate in the form of Func. The func is declared with input parameters of Type and string, whilst 'object' is the return object.

This func declaration is required as it is passed down into Unity's ObjectBuilder, which is responsible for creating a build plan for the creation of the object when resolving. This builder requires the context in which a build-up or tear-down operation runs. The builder context holds a key in the form of NamedTypeBuildKey which is how the object builder keeps track of exactly what is being built.

Type is the type of the build key, whilst the string relates to the name of the build key used to look up the type mappings.

So, the 'type' and 'string' parameters both relate the the build key used by Unity to track the plan for creating the objects registered in the container.

abrown
  • 715
  • 6
  • 17